From: Robert Klemme Date: 2013-05-27T21:36:24+09:00 Subject: Re: Wrong child process exit status if core dump / seg fault --001a11c2d084702b6404ddb265e2 Content-Type: text/plain; charset=ISO-8859-1 On Mon, May 27, 2013 at 2:21 PM, Alexander Schaal 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> $? => # 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> $? => # 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/ --001a11c2d084702b6404ddb265e2 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable



On Mon, May 27, 2013 at 2:21 PM, Alexander Schaal <lists@ruby-f= orum.com> wrote:
Update 1:
I am using ruby 1.9.3p194 (2012-04-20) [i386-mingw32].

Update 2:
With
=A0 =A0 result =3D 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 ) =3D 32
sizeof( pa ) =3D 4
sizeof(= ppa ) =3D 4
sizeof( b ) =3D 11
sizeof( c ) =3D 32
sizeof( d ) =3D 24
=
Segmentation fault
$ echo $?
139
$ irb
Ruby version 1.9.3
irb(main):001:0> system("./core")
sizeof( a ) =3D 32
sizeof( pa ) =3D = 4
sizeof( ppa ) =3D 4
sizeof( b ) =3D 11
sizeof( c ) =3D 32
sizeof( d ) =3D 24
=3D> false
<= div class=3D"gmail_extra"> irb(main):002:0> $?
=3D> #<Process= ::Status: pid 3824 SIGSEGV (signal 11)>
= irb(main):003:0> puts $?
pid 3824 SIGSEG= V (signal 11)
=3D> nil
irb(= main):004:0> $?.exitstatus
=3D> n= il
irb(main):006:0> RUBY_PATCHLEVEL
<= /div>
=3D> 392
$ ruby --version
= ruby 1.9.3p392 (2013-02-22) [i386-cygwin]


And also for non core:

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


This is most likely an= issue of your Windows version of Ruby. =A0On Linux it works the same as sh= own above.

Cheers

robert

--
remember.guy do |as, oft= en| as.you_can - without end
http://blog.rubybestpractices.com/
--001a11c2d084702b6404ddb265e2--