[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Segfaults, other signals, fork, etc.

Elliott Hird

4/21/2007 4:04:00 PM

I have this code:

Process.waitpid(fork { exec "stuff" })

Outside of the fork, how can i detect various signals sent to stuff?
SIGSEV, etc.

--
Posted via http://www.ruby-....

3 Answers

Robert Klemme

4/21/2007 4:32:00 PM

0

On 21.04.2007 18:03, Elliott Hird wrote:
> I have this code:
>
> Process.waitpid(fork { exec "stuff" })
>
> Outside of the fork, how can i detect various signals sent to stuff?
> SIGSEV, etc.

IIRC you can detect signals only from within the process that receives
those signals. So "stuff" would have to do it. If you want to
interfere with this you need to make sure that whoever sends those
signals sends them to the parent or some kind of proxy which can do
anything with them (including forwarding to the child).

I believe the only way to influence this from the outside is when
signals are set to "ignore". The child will inherit the ignoring even
after exec.

Kind regards

robert

Elliott Hird

4/21/2007 5:36:00 PM

0

Robert Klemme wrote:
> IIRC you can detect signals only from within the process that receives
> those signals. So "stuff" would have to do it. If you want to
> interfere with this you need to make sure that whoever sends those
> signals sends them to the parent or some kind of proxy which can do
> anything with them (including forwarding to the child).
Would it be possible with Kernel#system()?


> Kind regards
>
> robert


--
Posted via http://www.ruby-....

Nobuyoshi Nakada

4/22/2007 12:06:00 AM

0

Hi,

At Sun, 22 Apr 2007 01:03:51 +0900,
Elliott Hird wrote in [ruby-talk:248642]:
> I have this code:
>
> Process.waitpid(fork { exec "stuff" })
>
> Outside of the fork, how can i detect various signals sent to stuff?
> SIGSEV, etc.

You can detect how the child process exited with $?, or waitpid2.

$ ruby -e 'pid = fork {exec "sleep 10"}; sleep 0.1; Process.kill("TERM", pid); p Process.waitpid2(pid)'
[23366, #<Process::Status: pid=23366,signaled(SIGTERM=15)>]

--
Nobu Nakada