Hello!

On Fri, Mar 17, 2000 at 01:42:14AM -0800, Simon Marlow wrote:
> [...]

> > After looking at ghc 4.02's libraries for a while (it's all I had
> > around), it looks as though ghc-4.02/ghc/lib/std/cbits/system.c should
> > mask the SIGVTALRM signal after executing fork and before executing
> > exec*.  (Obviously it should also mask any other signals not set by
> > the users code.) 

> I don't get it - execve() and friends are supposed to reset all the signal
> handlers back to the default state, aren't they?  And I can't seem to
> construct an example to demonstrate the problem.

execve() keeps ignored signals ignored, the rest is reset to default.
Default handling for SIGALRM, SIGVTALRM and SIGPROF (the signals generated
by itimers) is terminating the process!

The correct handling would be:
- block SIGALRM/SIGVTALRM/SIGPROF
- *then* fork() (else you have a race condition where the child could
  receive *and handle* the signal)
- in the parent, unblock the signals
- in the child: unset the itimers (as suggested in my last mail)
- in the child: now, the signals can be unblocked as they're not generated
  any more
- in the child: you can safely exec()

> [...]

Regards, Hannah.

Reply via email to