X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



5492 Rate this article:
No rating

Access the PID of a process spawned by IDL (UNIX / Linux / Mac OS X) before SPAWN returns

QUESTION -

"On UNIX, Linux or Mac OS X, how can I SPAWN a separate program from IDL without waiting for that program to return and then be able to access the PID of that spawned program?"

Normally, if a user can wait for the IDL "SPAWN" procedure to return, the PID keyword to SPAWN can be used to get the spawned child process ID (PID). 

However, in the case where the spawned program must run synchronously with IDL, i.e., in the foreground while IDL execution waits, but the user would like to get the child PID before the child process returns control back to IDL, then an alternative approach is needed to get this information.

SOLUTION -

One approach might be to SPAWN a pair of commands: 

1.) First, print the PID of the spawned child shell to the terminal ("echo $$").

2.) Next, "exec" the target command in order to replace the child shell spawned by the IDL with the target command.  For example:

IDL> SPAWN, 'echo $$ ; exec xclock', PID=pid
26023

At this point, the PID of the child process is printed to screen and the user can then use PID information to access that exact child process outside of the context of IDL, while the spawned process continues to run synchronously with the IDL session.

Subsequently when the "xclock" window is closed, control returns back to the IDL prompt.  At that point you will have access to the child "pid" variable that is returned to the PID keyword assignment to the "pid" variable by SPAWN:

IDL> PRINT, pid
       26023

 

Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »