>In UNIX it is not safe to perform arbitrary actions after forking a >multi-threaded process. You're basically expected to call exec soon after the >fork, although >you can do certain other work if you are very careful.
>The reason for this is that after the fork, only one thread will be running in >the child, and if that thread tries to acquire a lock or other formerly-shared >resource >it may deadlock or crash, because the child process is no longer accessing the >same memory location as the threads in the parent process (it gets a separate >copy >of the address space at the time of fork, which may not be in a consistent >state from the point of view of the thread library). I am not calling fork explicitly. The thread I'm running in was created with pthread_create(). The fork() in the stack trace in my original email is being called by the system() function as it spawns off the process it is supposed want to run. Is there a safe way to call system() within a pthread? The app has several such threads doing various monitoring actions, some calling functions using system(), others invoking various C library routines. The parent process where these threads were spawned from is basically sleeping, waking up only periodically to check for shutdown events. _______________________________________________ firstname.lastname@example.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"