go***********@burditt.org (Gordon Burditt) writes:
"Guillaume Dargaud"
<us*****************************@www.gdargaud.netw rites:
>>I can launch an external program using system() or the exec() family of
calls.
exec*() are POSIX calls, not standard C.
>>But I'm under the impression that I then can't kill that process
using standard C functions.
It's worse than that. In standard C functions, you aren't guaranteed
to be able to have two processes active at the same time. system()
waits for the process to complete before returning (and whether or
not you can put a process into the background depends on the command
interpreter).
[...]
Not even that much is guaranteed. A conforming implementation could
have system() either wait or not wait for the executed program to
finish.
Here's what the standard says (C99 7.20.4.6):
If string is a null pointer, the system function determines
whether the host environment has a command processor. If string is
not a null pointer, the system function passes the string pointed
to by string to that command processor to be executed in a manner
which the implementation shall document; this might then cause the
program calling system to behave in a non-conforming manner or to
terminate.
If the argument is a null pointer, the system function returns
nonzero only if a command processor is available. If the argument
is not a null pointer, and the system function does return, it
returns an implementation-defined value.
I've restored the attribution line for the quoted material from
Guillaume Dargaud. Permission to quote this article without
attribution is denied.
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"