comp.lang.ada
 help / color / mirror / Atom feed
* Start_Process_Search error detection
@ 2008-02-13  1:53 David Shochat
  2008-02-14  8:26 ` Jacob Sparre Andersen
  0 siblings, 1 reply; 4+ messages in thread
From: David Shochat @ 2008-02-13  1:53 UTC (permalink / raw)


Posix/Ada, package Posix_Process_Primitives, includes a procedure 
Start_Process_Search which searches for the requested program using the 
value of the PATH environment variable. My question is, how do you detect 
that the search failed (or will fail)? The package spec we have is 
virtually devoid of documentation. Checking the returned process id does 
not work. I get a nonzero process id even when I pass a fictitious name. 
Also, no exception is raised. I could parse $PATH and check each 
directory, but there must be a better way. This is Apex on Solaris.
-- David





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Start_Process_Search error detection
  2008-02-13  1:53 Start_Process_Search error detection David Shochat
@ 2008-02-14  8:26 ` Jacob Sparre Andersen
  2008-02-14 11:06   ` David Shochat
  0 siblings, 1 reply; 4+ messages in thread
From: Jacob Sparre Andersen @ 2008-02-14  8:26 UTC (permalink / raw)


David Shochat <shochatd@yahoo.com> writes:

> Posix/Ada, package Posix_Process_Primitives, includes a procedure
> Start_Process_Search which searches for the requested program using
> the value of the PATH environment variable. My question is, how do
> you detect that the search failed (or will fail)? The package spec
> we have is virtually devoid of documentation. Checking the returned
> process id does not work. I get a nonzero process id even when I
> pass a fictitious name.  Also, no exception is raised. I could parse
> $PATH and check each directory, but there must be a better way. This
> is Apex on Solaris.

I haven't got any documentation either, but the Florist implementation
of POSIX.Process_Primitives.Start_Process_Search will give you a
negative value in the formal parameter Child, if the creation of a new
process failed.  If the creation didn't fail, you can use
POSIX.Process_Primitives.Wait_For_Chilt_Process to see if the child
process exited with the status Failed_Creation_Exit.

Greetings,

Jacob
-- 
"The early bird may get the worm, but the second mouse gets the cheese!"



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Start_Process_Search error detection
  2008-02-14  8:26 ` Jacob Sparre Andersen
@ 2008-02-14 11:06   ` David Shochat
  2008-02-14 15:34     ` Jacob Sparre Andersen
  0 siblings, 1 reply; 4+ messages in thread
From: David Shochat @ 2008-02-14 11:06 UTC (permalink / raw)


On Thu, 14 Feb 2008 09:26:21 +0100, Jacob Sparre Andersen wrote:

> I haven't got any documentation either, but the Florist implementation
> of POSIX.Process_Primitives.Start_Process_Search will give you a
> negative value in the formal parameter Child, if the creation of a new
> process failed.  If the creation didn't fail, you can use
> POSIX.Process_Primitives.Wait_For_Chilt_Process to see if the child
> process exited with the status Failed_Creation_Exit.
> 
I'm getting a positive pid so I guess the process creation is succeeding. 
But if I call Wait_For_Child_Process, in the successful case, won't that 
cause me to block? I don't want to wait until the process is done. 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Start_Process_Search error detection
  2008-02-14 11:06   ` David Shochat
@ 2008-02-14 15:34     ` Jacob Sparre Andersen
  0 siblings, 0 replies; 4+ messages in thread
From: Jacob Sparre Andersen @ 2008-02-14 15:34 UTC (permalink / raw)


David Shochat wrote:

> But if I call Wait_For_Child_Process, in the successful case, won't
> that cause me to block?

Only if you don't use the argument "Block => False".  But you would of
course have to be patient enough to give the child process time enough
to complete its attempt to load the new program.

Remember that even if you successfully verify that the program is
available before you call Start_Process_Search, you can't be sure that
it still is available once you actually call Start_Process_Search.

Greetings,

Jacob
-- 
"... there may be many others,
 but they haven't been discovered"             -- Tom Lehrer



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-02-14 15:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-13  1:53 Start_Process_Search error detection David Shochat
2008-02-14  8:26 ` Jacob Sparre Andersen
2008-02-14 11:06   ` David Shochat
2008-02-14 15:34     ` Jacob Sparre Andersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox