Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-03

sending signal to child process

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Tom Carly

Hi,

I have a process A that starts another process B (with TProcess.Create). I introduced signal handling for SIGHUP, SIGTERM and SIGINT in process A and process B. The signal handling of process A triggers a call to "fpkill(processA.processid, SIGTERM)" (or "processA.Terminate(0)"). This code is executed when killing process A.
The problem is that the signal handling code of process B is not executed when killing process A (although process B does get killed). If I launch process B separately and kill it, then the signal handling code of process B is executed. It seems that the signal that is sent from process A to process B is not the same as when you kill it via the command line.

Does anyone have an idea how to solve this?

Thanks!

Best regards,

Tom

Henry Vermaak
to Tom Carly

2009/3/30 Tom Carly :

Show quoted text 11 lines
Hi, I have a process A that starts another process B (with TProcess.Create). I introduced signal handling for SIGHUP, SIGTERM and SIGINT in process A and process B. The signal handling of process A triggers a call to “fpkill(processA.processid, SIGTERM)” (or “processA.Terminate(0)”).

do you mean processB.processid here?

Show quoted text 9 lines
This code is executed when killing process A. The problem is that the signal handling code of process B is not executed when killing process A (although process B does get killed). If I launch process B separately and kill it, then the signal handling code of process B is executed. It seems that the signal that is sent from process A to process B is not the same as when you kill it via the command line.

are the permissions the same for the two processes? are you sending sigterm from the commandline, too?

i've done something similar before, but using a different signal. that shouldn't matter, since sigterm can be blocked (unlike sigkill and sigstop).

henry

Tom Carly
to Henry Vermaak

Hi,

I found that the problem is coming from the fact that I use
process.Options := ProcessB.Options + [poUsePipes];

If I switch that off, process B does execute the signal handling code. Is this a bug or am I missing something?

Thx,

Tom

Earlier message 39 lines
-----Original Message----- From: On Behalf Of Henry Vermaak Sent: maandag 30 maart 2009 16:37 To: FPC-Pascal users discussions Subject: Re: [fpc-pascal] sending signal to child process 2009/3/30 Tom Carly : > Hi, > > > > I have a process A that starts another process B (with TProcess.Create). > > I introduced signal handling for SIGHUP, SIGTERM and SIGINT in process A and > process B. > > The signal handling of process A triggers a call to > "fpkill(processA.processid, SIGTERM)" (or "processA.Terminate(0)"). do you mean processB.processid here? > > This code is executed when killing process A. > > The problem is that the signal handling code of process B is not executed > when killing process A (although process B does get killed). > > If I launch process B separately and kill it, then the signal handling code > of process B is executed. It seems that the signal that is sent from process > A to process B is not the same as when you kill it via the command line. are the permissions the same for the two processes? are you sending sigterm from the commandline, too? i've done something similar before, but using a different signal. that shouldn't matter, since sigterm can be blocked (unlike sigkill and sigstop). henry
Henry Vermaak
to Tom Carly

2009/3/31 Tom Carly :

Show quoted text 6 lines
Hi, I found that the problem is coming from the fact that I use process.Options := ProcessB.Options + [poUsePipes]; If I switch that off, process B does execute the signal handling code. Is this a bug or am I missing something?

it would be great if you could make a bugrep with a very simple example.

henry