Re: SPAWN background command without nohup? [message #88869 is a reply to message #88867] |
Mon, 30 June 2014 04:17   |
lecacheux.alain
Messages: 325 Registered: January 2008
|
Senior Member |
|
|
On Monday, June 30, 2014 12:03:04 PM UTC+2, David Grier wrote:
> On Monday, June 30, 2014 5:34:13 AM UTC-4, alx wrote:
>
>> On Saturday, June 28, 2014 5:27:48 PM UTC+2, David Grier wrote:
>
>>
>
>>> Dear Folks,
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> Using SPAWN to start a background process on unix-like systems
>
>>
>
>>>
>
>>
>
>>> can leave the process running even after the IDL process terminates.
>
>>
>
>>>
>
>>
>
>>> I'd like to arrange things so that the child process is killed when IDL exits.
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> Here's a schematic example:
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> IDL> spawn, 'myprocess &', pid=pid
>
>>
>
>>>
>
>>
>
>>> IDL> print, pid
>
>>
>
>>>
>
>>
>
>>> 62417
>
>>
>
>>>
>
>>
>
>>> IDL> exit
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> $ ps | grep 62417
>
>>
>
>>>
>
>>
>
>>> grier 62417 0.0 0.1 2473856 12320 ?? S 10:41AM 0:00.02 myprocess
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> This is similar to running a shell command with nohup:
>
>>
>
>>>
>
>>
>
>>> $ nohup myprocess &
>
>>
>
>>>
>
>>
>
>>> $ exit
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> Is there a way to make IDL spawn a child process that terminates when
>
>>
>
>>>
>
>>
>
>>> the parent IDL session terminates?
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> All the best,
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> David
>
>>
>
>>
>
>>
>
>> You might try to keep your spawned process synchronized with the parent IDL session : maybe by using the UNIT keyword ?
>
>>
>
>> Just a guess, I have no experience with unix.
>
>>
>
>> alx.
>
>
>
> Thanks for thinking about this.
>
>
>
> Using the UNIT keyword is indeed useful for shutting down the child process from the parent IDL session. It doesn't help, however, if the user exits IDL without actively shutting down the
>
> child process.
>
>
>
> I'm looking for a way to spawn a child process that runs in the background and cleanly quits when
>
> the parent IDL session ends.
>
>
>
> All the best,
>
>
>
> David
> I'm looking for a way to spawn a child process that runs in the background and cleanly quits when
Maybe by using some shared object ? A semaphore or a global memory region. But you would have to modify your child process accordingly.
alx.
|
|
|