# Abort a system call

**URL:** <https://rubytalk.org/t/abort-a-system-call/19345>\
**Category:** ruby-talk\
**Created:** [5 July 2005 10:58 UTC](https://rubytalk.org/t/abort-a-system-call/19345 "2005-07-05T10:58:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Masschelein\_Bart](https://avatars.discourse-cdn.com/v4/letter/m/7bcc69/32.png) [@Masschelein\_Bart](https://rubytalk.org/u/Masschelein_Bart)\
**Post date:** [5 July 2005 10:58 UTC](https://rubytalk.org/t/abort-a-system-call/19345/1 "2005-07-05T10:58:04Z")

</div>

> \> When I do in Perl sth like  
> \>  
> \> system "$decoder $bitstreamPath $yuvOutputPath";  
> \>  
> \> I can interrupt the execution with ctrl-c. The Ruby script does what  
> \> it is expected to, but I cannot interrupt the program with ctrl-c  
> \> anymore, and have to wait until the execution is finished.
> 
> Without trying out: maybe you have to explicitely set a  
> signal handler for  
> SIGINT that then terminates the child process. Could be that  
> perl does it  
> automatically for you.

With parts of other pieces today on the reflector, I assembled this

> **···**
>
> --------  
> pid = Process.fork do  
> &nbsp;&nbsp;exec($decoder, $bitstreamPath, $yuvOutputPath)  
> end
> 
> trap "SIGINT", proc{ Process.kill("SIGINT", pid); print "^C was pressed. Process id #{pid}\n" }
> 
> Process.waitpid(pid)  
> --------
> 
> The trap gets executed, meaning that I get the output of the print, during the execution of my program, and the pid matches the one from the process status list. However the first part (Process.kill("SIGINT", pid)😉 is not executed correctly, or at least does not do what I expected, killing the process. Is there another way to kill a process from Ruby? Or do I need another signal # instead of "SIGINT" there? No clue...
> 
> regards,
> 
> Bart.
