Re: Can fork be used in a signal handler?
- From: James Carlson <james.d.carlson@xxxxxxx>
- Date: 28 Mar 2008 10:58:45 -0400
kiran <edu.mvk@xxxxxxxxx> writes:
I have a problem that i have to create a new process, when my process
gets a SIGCHLD.
So i want to use fork inside the signal handler for SIGCHLD.
Have you read the documentation for the operating system you're using?
You didn't say what you're using, but on Solaris I see this for
fork(2):
| MT-Level | Async-Signal-Safe. |
and the attributes(5) page says:
Async-Signal-Safe
Async-Signal-Safe refers to particular library functions
that can be safely called from a signal handler. A
thread that is executing an Async-Signal-Safe function
will not deadlock with itself if interrupted by a sig-
nal. Signals are only a problem for MT-Safe functions
that acquire locks.
Async-Signal-Safe functions are also MT-Safe. Signals
are disabled when locks are acquired in Async-Signal-
Safe functions. These signals prevent a signal handler
that might acquire the same lock from being called.
So, you can do it there at least.
And in the signal handler i'm traversing a linked list which has the
complexity of O(n2). Is that ok if a signal handler to be that heavy?
Note: no global variables are being changed inside the handler.
That's something you'll have to evaluate on your own. Nobody here
knows the underlying requirements or detailed design of your program.
--
James Carlson, Solaris Networking <james.d.carlson@xxxxxxx>
Sun Microsystems / 35 Network Drive 71.232W Vox +1 781 442 2084
MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax +1 781 442 1677
.
- References:
- Can fork be used in a signal handler?
- From: kiran
- Can fork be used in a signal handler?
- Prev by Date: Re: 64-bit c++ application crashing on solaris
- Next by Date: list of posix typedefs?
- Previous by thread: Re: Can fork be used in a signal handler?
- Next by thread: 64-bit c++ application crashing on solaris
- Index(es):
Relevant Pages
|