help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BASH Processes


From: David Grundberg
Subject: Re: BASH Processes
Date: Wed, 14 Apr 2010 08:32:30 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4

On 04/14/2010 05:07 AM, Mike B. wrote:
Dear all,

I'm using Octave 3.2.4 in Debian. Two quick questionso on starting processes 
with system:

1. When issuing
sleep 20&

from the bash commandline it immediately returns to the prompt (runs in the 
background) but when doing
system( "sleep 20&" )

from octave it waits for 20 sec. before returning. Why is that?.

No, that will never work since Octave waits for the shell process, not the sleep one. Octave doesn't even know of the existence of the sleep process, so it won't matter what job control the sleep process is exposed to.

What Octave is doing is more like writing

  bash -c 'sleep 20 &'

at the shell prompt, instead of sleep 20 & directly.

2. When starting a process in the background bash returns the process ID (PID), 
for example:
sleep 20&
[1] 20885

so 20885 is the PID. How can I read this output in octave?. The `system' 
command returns a different PID (not of the actual process started).

Thanks,
Mike.

Yes, it returns the pid of the shell process (probably bash) that interprets the input "sleep 20 &".

I guess you want to do something like this in Octave:

  pid = system ("sleep 1; echo foobar", [], "async")

Hope this was helpful,
David


reply via email to

[Prev in Thread] Current Thread [Next in Thread]