From: "Mauricio Fernández" Date: 2003-02-27T21:25:59+09:00 Subject: Re: Threads, pipes, popen, whatever On Thu, Feb 27, 2003 at 09:19:10PM +0900, Robert Klemme wrote: > > "Brian Candler" schrieb im Newsbeitrag > news:20030227105024.A89394@linnet.org... > > On Thu, Feb 27, 2003 at 06:57:18PM +0900, Michael Shigorin wrote: > > > On Tue, Feb 25, 2003 at 05:52:08PM +0900, Robert Klemme wrote: > > > > Normally you would use IO.popen but I can't see a way to access > > > > the exit status of the process directly. > > > > > > $? won't work? > > > > It does appear to work as advertised: > > Thanks for the hint! > > > f = IO.popen("/usr/bin/false","w") > > f.write "ignoreme" > > f.close > > puts $? #>> 256 > > > > It would be nice if the status hung around as an instance variable of f > > though. > > Yes, I did not think of looking for a global variable. This is a nice > example of the drawbacks: If two threads use popen you can't be sure any > more that the value you read from $? is the correct one. Nope, $? is thread local. -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com *** Rince is wagner@schizo.DAINet.de (We have Joey, we have Fun, we have Linux on a Sun) -- Seen on #Debian