From: tadump+ruby-lang@... Date: 2017-04-23T23:05:06+00:00 Subject: [ruby-core:80838] [Ruby trunk Bug#13501] Process.kill behaviour for negative pid is not documented and may be wrong Issue #13501 has been reported by toy (Ivan Kuchin). ---------------------------------------- Bug #13501: Process.kill behaviour for negative pid is not documented and may be wrong https://bugs.ruby-lang.org/issues/13501 * Author: toy (Ivan Kuchin) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.2.7p470 (2017-03-28 revision 58194) [x86_64-darwin14] * Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN ---------------------------------------- Following code will not fail and will print "TERM caught by NN" both for spawned and forked processes: ~~~ ruby pid = spawn 'ruby', '-e', <<-'RUBY', :pgroup => true trap('TERM'){ print "TERM caught by #{$$}\n" } fork sleep 10 RUBY sleep 1 Process.kill('TERM', -pid) ~~~ Documentation explains such behaviour for using negative signal (or a string starting with '-'), but not negative pid. [linux](https://linux.die.net/man/2/kill), [osx](https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man2/kill.2.html) and [POSIX](http://pubs.opengroup.org/onlinepubs/009695399/functions/kill.html) documentation for `kill` describes behaviour for negative pid is to send signal to process group. As `Process.kill` is [using `killpg`](https://github.com/ruby/ruby/blob/e97ac02f8466275732a33f704480c03da722f485/signal.c#L464) if it is defined, the behaviour may be undefined on systems with `killpg` present but `kill` not conforming to `POSIX` specification. Also sending negative `signal` with negative `pid` will call `killpg` with negative `pid`. -- https://bugs.ruby-lang.org/ Unsubscribe: