Logan Capaldo
8/3/2006 2:49:00 PM
On Aug 3, 2006, at 10:40 AM, Daniel N wrote:
> On 8/4/06, Christopher Brown <cbrown@atbash.net> wrote:
>>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> If the IO::popen is creating a child process, how about calling
>> Process.waitpid? Once that returns, the subprocess will have
>> completed and the file should be complete.
>>
>> Cheers,
>> Chris
>
>
>
> How would I get the pid that the child process is on?
>
You could just use Process.waitall (Or Process.wait() if you're
feeling lucky)
> On 03 Aug 2006, at 6:29 AM, Daniel N wrote:
>>
>> > Hi,
>> >
>> > I've just installed and had some success with the gnuplot library.
>> >
>> > I'm saving the output to a png file (plot.terminal "png") and this
>> > all works
>> > well, but when I try to use the file it isn't finished writing it
>> > yet and I
>> > get an exception.
>> >
>> > I've used
>> >
>> > Gnuplot.open( ) do |gp|
>> > ....
>> > end
>> >
>> > while(!File.exists?("/test2.png") || File.zero?("/test2.png") )
>> > sleep 0.1
>> > end
>> >
>> > In an attempt to wait until the file is written before I try to do
>> > anything
>> > with it, but this seems a bit too hackish.
>> >
>> > Can I capture the Gnuplot.open into a variable and check it?
>> The last
>> > statement in the Gnuplot.open is a call to
>> > IO::popen( cmd, "w") { |io| yield io }
>> >
>> > but if I test the class of what is returned it is
>> > Gnuplot::Plot
>> >
>> > not anything to do with IO
>> >
>> > Is there a way that I can test the IO::popen to tell when it's
>> > finished?
>>
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.3 (Darwin)
>>
>> iD8DBQFE0gh+rOGxDZoCCzURAuTIAKDYiSODiBkrNJRa16V/VzSybhLb/wCgm/7C
>> BgaaVLCVUlngxwov8RNO8JY=
>> =qb5q
>> -----END PGP SIGNATURE-----
>>
>>