Sponsored Content
Full Discussion: pthreads invoking atexit()
Top Forums Programming pthreads invoking atexit() Post 23969 by hell666 on Wednesday 3rd of July 2002 07:17:06 AM
Old 07-03-2002
atexit() is a function which registers another function (handler) to be invoked when your program is about to quit, and is not a function which is itself invoked during then. Also, this is a routine invoked only when there was a normal termination from your program, not otherwise (kill).
If you meant the function registered with atexit() is invoked after your second sql function, check to see if there was some SQL error in that function, which inturn was calling exit().
Also, post some relevant code, it would be helpful in analysing the situation better.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

PThreads

Can anyone explain me how to use pthread_key_create() , pthread_setspecific(), pthread_getspecific() and pthread_key_delete () routines in pthreads. Kindly state by an example. (3 Replies)
Discussion started by: S.P.Prasad
3 Replies

2. Programming

pthreads

Does any one no of some good web site which will explain about how to program using pthreads in a UNIX enviroment? (6 Replies)
Discussion started by: fishman2001
6 Replies

3. Programming

pthreads

howcome that pthtreads spawn 2 extra processes? I'm kind of new with pthreads but fork() did not act like this. Anyone who can give me a technical explanation of what happends with mother / daughter processes? Best regards Esaia. (2 Replies)
Discussion started by: Esaia
2 Replies

4. Programming

PThreads

I have created a thread program, it is attached. My problem is that I need to loop this program multiple times, and basically reset everything including the threads created previously. I try to loop the program, the first run is fine, as always, but the second run of the program, the initialize... (0 Replies)
Discussion started by: justgotthis
0 Replies

5. Programming

Behavior of pthreads

Hi All, I ve written a small program to get started off with pthreads. I somehow feel the program doesnt meet the purpose. Please find the code and the output below. Please find my question at the bottom. #include <pthread.h> #include <stdio.h> #include <stdlib.h> void *PrintThread1(void... (4 Replies)
Discussion started by: nhrraj
4 Replies

6. UNIX for Dummies Questions & Answers

Question on Pthreads

How to give superuser privileges while setting the attributes like pthread_attr_setschedpolicy( )?? Even with normal user mode ,it is working fine for me.But in man pages, they have specied that to set the scheduling policy as SCHED_FIFO, the process should have superuser privileges. (0 Replies)
Discussion started by: yashavant.a
0 Replies

7. HP-UX

pthreads

Hi! I'm linking my hpux code using -lpthread (gcc), yet it references libpthread_tr.1, the debug version of the pthread lib. How do I force it to use pthreads? Thanks, :) (3 Replies)
Discussion started by: zackz
3 Replies

8. Programming

Problem with pthreads

hi i have a code: I found that after exiting from child thread memory isn't freed. I commented everything which is "some actions" here, so thread's function contains only two lines. But it doesn't help. What do I do wrong? Thanks a lot (3 Replies)
Discussion started by: sery0ga
3 Replies

9. Programming

MultiThreading using Pthreads

Situation: i have multiple pthread_create calls like this: pthread_create(...., ThreadFunc1,.....); pthread_create(...., ThreadFunc2,.....); . . which i am using to create multiple threads.All the "ThreadFunc<i>" functions are actually calling same function "Receive" of a class using same... (3 Replies)
Discussion started by: Sastra
3 Replies

10. Programming

Idleness with pthreads

Hello, I am writing a threaded program using the pthread library in linux. I have a master thread that needs to control worker threads, in particular, it has to be able to ensure that none of the worker threads will be running for a specified amount of time, even if the worker threads are... (7 Replies)
Discussion started by: andres625
7 Replies
ATEXIT(3)						     Linux Programmer's Manual							 ATEXIT(3)

NAME
atexit - register a function to be called at normal process termination SYNOPSIS
#include <stdlib.h> int atexit(void (*function)(void)); DESCRIPTION
The atexit() function registers the given function to be called at normal process termination, either via exit(3) or via return from the program's main(). Functions so registered are called in the reverse order of their registration; no arguments are passed. The same function may be registered multiple times: it is called once for each registration. POSIX.1 requires that an implementation allow at least ATEXIT_MAX (32) such functions to be registered. The actual limit supported by an implementation can be obtained using sysconf(3). When a child process is created via fork(2), it inherits copies of its parent's registrations. Upon a successful call to one of the exec(3) functions, all registrations are removed. RETURN VALUE
The atexit() function returns the value 0 if successful; otherwise it returns a nonzero value. ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7). +----------+---------------+---------+ |Interface | Attribute | Value | +----------+---------------+---------+ |atexit() | Thread safety | MT-Safe | +----------+---------------+---------+ CONFORMING TO
POSIX.1-2001, POSIX.1-2008, C89, C99, SVr4, 4.3BSD. NOTES
Functions registered using atexit() (and on_exit(3)) are not called if a process terminates abnormally because of the delivery of a signal. If one of the functions registered functions calls _exit(2), then any remaining functions are not invoked, and the other process termina- tion steps performed by exit(3) are not performed. POSIX.1 says that the result of calling exit(3) more than once (i.e., calling exit(3) within a function registered using atexit()) is unde- fined. On some systems (but not Linux), this can result in an infinite recursion; portable programs should not invoke exit(3) inside a function registered using atexit(). The atexit() and on_exit(3) functions register functions on the same list: at normal process termination, the registered functions are invoked in reverse order of their registration by these two functions. According to POSIX.1, the result is undefined if longjmp(3) is used to terminate execution of one of the functions registered using atexit(). Linux notes Since glibc 2.2.3, atexit() (and on_exit(3)) can be used within a shared library to establish functions that are called when the shared library is unloaded. EXAMPLE
#include <stdio.h> #include <stdlib.h> #include <unistd.h> void bye(void) { printf("That was all, folks "); } int main(void) { long a; int i; a = sysconf(_SC_ATEXIT_MAX); printf("ATEXIT_MAX = %ld ", a); i = atexit(bye); if (i != 0) { fprintf(stderr, "cannot set exit function "); exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); } SEE ALSO
_exit(2), dlopen(3), exit(3), on_exit(3) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. Linux 2017-09-15 ATEXIT(3)
All times are GMT -4. The time now is 07:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy