| Store | Cart

Re: Wrong child process exit status if core dump / seg fault

From: Robert Klemme <shor...@googlemail.com>
Mon, 27 May 2013 21:36:24 +0900
On Mon, May 27, 2013 at 2:21 PM, Alexander Schaal <lis...@ruby-forum.com>wrote:

> Update 1:> I am using ruby 1.9.3p194 (2012-04-20) [i386-mingw32].>> Update 2:> With>     result = system('...')> I can see if the exit code is zero or not EVEN if the process terminates> with seg fault / core dump.>

Hmm, works for me in case of core:

$ gcc -Wall -ansi -o core x.c
$ ./core
sizeof( a ) = 32
sizeof( pa ) = 4
sizeof( ppa ) = 4
sizeof( b ) = 11
sizeof( c ) = 32
sizeof( d ) = 24
Segmentation fault
$ echo $?
139
$ irb
Ruby version 1.9.3
irb(main):001:0> system("./core")
sizeof( a ) = 32
sizeof( pa ) = 4
sizeof( ppa ) = 4
sizeof( b ) = 11
sizeof( c ) = 32
sizeof( d ) = 24
=> false
irb(main):002:0> $?
=> #<Process::Status: pid 3824 SIGSEGV (signal 11)>
irb(main):003:0> puts $?
pid 3824 SIGSEGV (signal 11)
=> nil
irb(main):004:0> $?.exitstatus
=> nil
irb(main):006:0> RUBY_PATCHLEVEL
=> 392
$ ruby --version
ruby 1.9.3p392 (2013-02-22) [i386-cygwin]


And also for non core:

irb(main):001:0> system "test.exe"
=> false
irb(main):002:0> $?
=> #<Process::Status: pid 7996 exit 1>
irb(main):003:0> $?.exitstatus
=> 1


This is most likely an issue of your Windows version of Ruby.  On Linux it
works the same as shown above.

Cheers

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Recent Messages in this Thread
Alexander Schaal May 27, 2013 09:39 am
Alexander Schaal May 27, 2013 12:21 pm
Robert Klemme May 27, 2013 12:36 pm
Alexander Schaal May 27, 2013 02:38 pm
Alexander Schaal May 27, 2013 02:41 pm
Alexander Schaal May 27, 2013 02:58 pm
Robert Klemme May 27, 2013 03:33 pm
Alexander Schaal May 27, 2013 03:57 pm
Alexander Schaal May 27, 2013 04:01 pm
Messages in this thread