# How to call system having trap("CHLD", "IGNORE")?

**URL:** <https://www.ruby-forum.com/t/how-to-call-system-having-trap-chld-ignore/98726>\
**Category:** Ruby\
**Created:** [July 17, 2006, 8:08pm UTC](https://www.ruby-forum.com/t/how-to-call-system-having-trap-chld-ignore/98726 "2006-07-17T20:08:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![elgato](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@elgato](https://www.ruby-forum.com/u/elgato)\
**Post date:** [July 17, 2006, 8:08pm UTC](https://www.ruby-forum.com/t/how-to-call-system-having-trap-chld-ignore/98726/1 "2006-07-17T20:08:07Z")

</div>

Hi all,

doing some forks I want to ignore SIGCHLD. But

trap(“CHLD”, “IGNORE”)  
system “echo”

ends in ruby 1.8.2 (2005-04-11) [i386-linux] with a following error:

in `system’: no implicit conversion from nil to integer (TypeError)

Where I am wrong?

Thanks,

P.

---

<div class="post-metadata">

**Author:** ![elgato](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@elgato](https://www.ruby-forum.com/u/elgato)\
**Post date:** [July 17, 2006, 9:56pm UTC](https://www.ruby-forum.com/t/how-to-call-system-having-trap-chld-ignore/98726/2 "2006-07-17T21:56:23Z")

</div>

On Tue, 18 Jul 2006, Pavel S. wrote:

> Where I am wrong?
> 
> Thanks,
> 
> P.

it looks like a bug.

try

trap(‘SIGCHLD’){ nil }

-a

---

<div class="post-metadata">

**Author:** ![elgato](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@elgato](https://www.ruby-forum.com/u/elgato)\
**Post date:** [July 18, 2006, 7:39am UTC](https://www.ruby-forum.com/t/how-to-call-system-having-trap-chld-ignore/98726/3 "2006-07-18T07:39:40Z")

</div>

Hi,

In message “Re: How to call system having trap(“CHLD”, “IGNORE”)?”  
on Tue, 18 Jul 2006 03:05:07 +0900, Pavel S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
writes:

|doing some forks I want to ignore SIGCHLD. But  
|  
|trap(“CHLD”, “IGNORE”)  
|system “echo”  
|  
|ends in ruby 1.8.2 (2005-04-11) [i386-linux] with a following error:  
|  
|in `system’: no implicit conversion from nil to integer (TypeError)  
|  
|Where I am wrong?

system() tried to pick up the exit status of forked sub-process.  
Since you’ve set SIG\_IGN sub-process disappeared without notice to  
wait(2) system call, which failed and caused an error you’ve seen.  
What did you try to accomplish by ignoring SIGCHLD?

It is fairly easy to make system to ignore wait(2) error, but I am not  
sure it is the way to go.

```
						matz.

```

---

<div class="post-metadata">

**Author:** ![elgato](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@elgato](https://www.ruby-forum.com/u/elgato)\
**Post date:** [July 18, 2006, 1:38pm UTC](https://www.ruby-forum.com/t/how-to-call-system-having-trap-chld-ignore/98726/4 "2006-07-18T13:38:57Z")

</div>

Hi,

In message “Re: How to call system having trap(“CHLD”, “IGNORE”)?”  
on Tue, 18 Jul 2006 20:26:38 +0900, “Robert D.”  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|Hmm I conclude from your reply (and tested)  
|trap(‘CHILD’, ‘IGNORE’) and  
|trap(‘CHILD’){ nil }  
|do not have the same semantics.

No they don’t. The former ignores SIGCHLD. The latter handles  
SIGCHLD and invokes empty signal handler.

---

<div class="post-metadata">

**Author:** ![elgato](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@elgato](https://www.ruby-forum.com/u/elgato)\
**Post date:** [July 18, 2006, 1:29pm UTC](https://www.ruby-forum.com/t/how-to-call-system-having-trap-chld-ignore/98726/5 "2006-07-18T13:29:42Z")

</div>

On 7/18/06, Yukihiro M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> |system “echo”  
> What did you try to accomplish by ignoring SIGCHLD?
> 
> It is fairly easy to make system to ignore wait(2) error, but I am not  
> sure it is the way to go.
> 
> ```
> matz.
> 
> ```

Hmm I conclude from your reply (and tested)  
trap(‘CHILD’, ‘IGNORE’) and  
trap(‘CHILD’){ nil }  
do not have the same semantics.  
Why should it be a bad idea to allow ignorining a Signal one can handle?

Just my 2\*\*(-10) â?¬ 😉

Robert

–  
Deux choses sont infinies : l’univers et la bÃªtise humaine ; en ce qui  
concerne l’univers, je n’en ai pas acquis la certitude absolue.

- Albert Einstein
