...
+#ifdef __ARCH_USE_MMU__
+       /* Upon _exit of the parent we may get a HUP that we do not want.  */
+       sigemptyset(&new_set);
+       sigaddset(&new_set, SIGHUP);
+       fd = sigprocmask(SIG_BLOCK, &new_set, &old_set);
+#else
...

I have tested this on my platform. It does not work.

My analysis:
" sigprocmask(SIG_BLOCK...)" does not eliminate the signal, it just delays its 
delivery.
See "man 7 signal", where "sigprocmask()" is described --> " A signal may be 
blocked, which means that it will not be delivered until it is later 
unblocked.".
So the SIGHUP delivered before the child has detached, is received at the child 
after it is unblocked.

Note:
This attempted to solves the problem for SIGHUP, but this type of solution 
(theoretically) leaves "holes" for other events or races.
It does not solve the main problem - the parent must not exit before the child 
has completely detached itself.

Therefore, I would again like to suggest my type of solution (tested, works) :
- Create a pipe before the fork().
- fork()
- The parent does a "read" from the pipe. It is blocked.
- The child does :
  * setsid() /* and is now detached */
  * "write" to the pipe
  * close pipe
- The parent is unblocked from the "read". It can now close the pipe and safely 
exit, since the child is detached.
- Any side affects of the parent exit (e.g. SIGHUP to the pgrp) will have no 
effect on the child, since it is detached.

Eli Stern
---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to