Sujet : Re: Running an editor from ANSI C
De : jameskuyper (at) *nospam* alumni.caltech.edu (James Kuyper)
Groupes : comp.lang.cDate : 08. Jun 2024, 06:54:56
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v40rnj$2g7r9$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14
User-Agent : Mozilla Thunderbird
On 2024-06-07, Malcolm McLean <
malcolm.arthur.mclean@gmail.com> wrote:
On 07/06/2024 21:04, Scott Lurndal wrote:
How does your pure "C" shell
spawn a new process without using posix or other OS-specific
APIs?
>
It can call "system".
I gather that you insist on using C90, so I'll quote from the C90
standard, but everything I'm about to say is equally a problem with the
current C standard:
7.10.4.5:
"Description
The system function passes the string pointed to by string to the host
environment to be executed by a command processor in an
implementation-defined manner. A null pointer may be used for string to
inquire whether a command processor exists.
Returns
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, the system function returns an implementation-defined value."
Note in particular: whether the system even has a a command processor
depends upon the operating system. The manner in which the command
string is processed and the meaning of system()'s nonzero return values
depend upon the operating system as well, though the C implementation is
required to document it. There's no way to write portable C code that
calls system().