[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Abort a system call

Masschelein Bart

7/4/2005 12:24:00 PM

Hello everyone,

I'm new to Ruby, a friend talked about it some days ago with great pleasure, so I was interested in giving it a shot. I was quite happy when I saw that the Perl scripts I had only required little change to still be working in Ruby. They are simple scripts though, mainly system call wrappers. But here is exactly where the problem comes. 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. I tried several alternatives:

system "#{$decoder} #{$bitstreamPath} #{$yuvOutputPath}";
syscall "#{$decoder} #{$bitstreamPath} #{$yuvOutputPath}";
exec "#{$decoder} #{$bitstreamPath} #{$yuvOutputPath}";
system $decoder, $bitstreamPath, $yuvOutputPath

but none is interuptable... is there something fundamental I am missing in the way Ruby handles system calls?

Oh, I am running Cygwin on 2000. In case its important.

Bart.
2 Answers

Robert Klemme

7/4/2005 1:34:00 PM

0

Masschelein Bart wrote:
> Hello everyone,
>
> I'm new to Ruby, a friend talked about it some days ago with great
> pleasure, so I was interested in giving it a shot. I was quite happy
> when I saw that the Perl scripts I had only required little change to
> still be working in Ruby. They are simple scripts though, mainly
> system call wrappers. But here is exactly where the problem comes.
> 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. I tried
> several alternatives:
>
> system "#{$decoder} #{$bitstreamPath} #{$yuvOutputPath}";
> syscall "#{$decoder} #{$bitstreamPath} #{$yuvOutputPath}";
> exec "#{$decoder} #{$bitstreamPath} #{$yuvOutputPath}";
> system $decoder, $bitstreamPath, $yuvOutputPath
>
> but none is interuptable... is there something fundamental I am
> missing in the way Ruby handles system calls?
>
> Oh, I am running Cygwin on 2000. In case its important.
>
> Bart.

Robert Klemme

7/4/2005 1:35:00 PM

0

Masschelein Bart wrote:
> Hello everyone,
>
> I'm new to Ruby, a friend talked about it some days ago with great
> pleasure, so I was interested in giving it a shot. I was quite happy
> when I saw that the Perl scripts I had only required little change to
> still be working in Ruby. They are simple scripts though, mainly
> system call wrappers. But here is exactly where the problem comes.
> 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. I tried
> several alternatives:
>
> system "#{$decoder} #{$bitstreamPath} #{$yuvOutputPath}";
> syscall "#{$decoder} #{$bitstreamPath} #{$yuvOutputPath}";
> exec "#{$decoder} #{$bitstreamPath} #{$yuvOutputPath}";
> system $decoder, $bitstreamPath, $yuvOutputPath
>
> but none is interuptable... is there something fundamental I am
> missing in the way Ruby handles system calls?
>
> Oh, I am running Cygwin on 2000. In case its important.
>
> Bart.

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.

Kind regards

robert