(Process.wait2)[1]

A

Ara.T.Howard

my understanding was that Process.wait2[1] would be the child process
exit_status, so this is confusing:

~ > ls -e; echo $?
ls: invalid option -- e
Try `ls --help' for more information.
1

~ > ruby -e 'fork{exec "ls -e"}; puts((Process.wait2)[1])'
ls: invalid option -- e
Try `ls --help' for more information.
256

~ > ruby -e 'fork{exec "ls -e"}; puts((Process.wait2))'
ls: invalid option -- e
Try `ls --help' for more information.
3388
256

~ > ruby -e 'fork{exec "ls -e"}; p((Process.wait2))'
ls: invalid option -- e
Try `ls --help' for more information.
[3399, #<Process::Status: pid=3399,exited(1)>]

obviously 256 is 1 << 8 and this is equivalent to $? - the exitstatus. can
someone eplain what the lower byte is then?


-a
--

ATTN: please update your address books with address below!

===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| STP :: http://www.ngdc.noaa.gov/stp/
| NGDC :: http://www.ngdc.noaa.gov/
| NESDIS :: http://www.nesdis.noaa.gov/
| NOAA :: http://www.noaa.gov/
| US DOC :: http://www.commerce.gov/
|
| The difference between art and science is that science is what we
| understand well enough to explain to a computer.
| Art is everything else.
| -- Donald Knuth, "Discover"
|
| /bin/sh -c 'for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done'
===============================================================================
 
A

Andrew Walrond

obviously 256 is 1 << 8 and this is equivalent to $? - the exitstatus. can
someone eplain what the lower byte is then?

see man 2 wait, and include/sys/wait.h

Andrew Walrond
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

tk file dialog and directories 3
[RCR/BUG?] fix system 8
pp equiv of #inspect 1
[BUG] greedy gsub 1
eistein's riddle 7
install.rb (modified for bin programs) 0
[RCR] Kernel#hostname 0
puts(derived_from_array) 0

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top