Mail Archives: djgpp/2001/05/18/05:55:37
> Date: Fri, 18 May 2001 11:29:40 +0300
> From: "NirinaMichel Ratoandromanana/DF" <n DOT ratoandromanana AT bni DOT mg>
>
> eliz AT is DOT elta DOT co DOT il a crit:
> >Please show a short test program which exhibits the problem. It is
> >impossible to help you without seeing the code which fails.
>
> if (spawnvp(P_WAIT, "gcc", NULL) == -1)
> printf ("spawn...() error!\n");
> What's wrong?
The way you call spawnvp is incorrect. The prototype of this
function, as documented in the library reference, is this:
int spawnvp(int mode, const char *path, const char **argv);
Your call puts a NULL pointer into the argv[] array passed to the
child program. That's invalid usage: argv[] should at least have the
argv[0] element non-NULL.
Here's the correct way of doing this:
char *argv[] = { "gcc", NULL };
if (spawnvp(P_WAIT, "gcc", argv) == -1)
printf ("spawn...() error!\n");
- Raw text -