2

well, I have a usr1 signal handler in a script. By sending a SIGUSR1 from outside to my script, my handler does its work, but the signal is spread also to the child that I create via Popen. How can I do this?

ScotchAndSoda
  • 3,811
  • 4
  • 34
  • 38
  • Signals don't "spread" by default; you're relaying it yourself. – phihag Oct 02 '12 at 15:40
  • @phihag nope, I simply make a subprocess.Popen in a script X. Then I'm sending a SIGUSR1 from outside and I'm catching it in my script. At the time my inner script cries because of sending him SIGUSR1 that I've never addressed to him. – ScotchAndSoda Oct 02 '12 at 15:45
  • @Method [Here is a demo](https://gist.github.com/3820337) that on my system outputs `parent: SIGUSR1 caught` (+ the PIDs). Can you reproduce that behavior? If not, what Python interpreter are you using, and on what OS? If so, how does your script differ from the demo script? – phihag Oct 02 '12 at 15:56
  • @phihag my case is a quite different from your exemple, thank you for it. In my script I use subprocess.Popen(), but not subprocess.call(), anyway it should not change the fork behaviour. In my script I Popen the rsync program. After sending my signal, my handler says "Got it", but rsync is exiting with error code 20, which means that it has caught the sigusr1 signal. – ScotchAndSoda Oct 02 '12 at 16:10
  • @Method `subprocess.call` is just an interface for `subprocess.Popen`. No offense, but it is [extremely unlikely](http://blogs.msdn.com/b/oldnewthing/archive/2011/02/10/10127054.aspx) that there is some kind of fundamental breakdown of your OS kernel that would cause a signal to "spread". Can you reduce the problem to [a reproducible example](http://sscce.org/)? – phihag Oct 02 '12 at 16:20
  • @phihag I agree for the similarity of popen as call and I've mentioned. – ScotchAndSoda Oct 02 '12 at 16:25
  • I think that I've found my problem. By coincidence rsync is pretending to recieve sigusr1 if killing it (what I do somewhere in my script by kill -15). So that has nothing to do with my sigusr1 sending from outside. – ScotchAndSoda Oct 02 '12 at 16:28

1 Answers1

0

The rsync manual page says that exit code 20 means:

Received SIGUSR1 or SIGINT

So if you are killing it with kill (not kill -15 which you say you sometimes use) then it would die with this exit code too.

qris
  • 7,900
  • 3
  • 44
  • 47