www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/05/18/05:55:37

Date: Fri, 18 May 2001 12:53:19 +0300
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: n DOT ratoandromanana AT bni DOT mg
Message-Id: <2427-Fri18May2001125319+0300-eliz@is.elta.co.il>
X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.9
CC: djgpp AT delorie DOT com
In-reply-to: <fc.000f77f3000f9130000f77f3000f8d9e.f914c@bni.mg>
(n DOT ratoandromanana AT bni DOT mg)
Subject: Re: spawn() problem.
References: <fc DOT 000f77f3000f8d9e000f77f3000f8d9e DOT f8da1 AT bni DOT mg>
<3405-Fri18May2001104125+0300-eliz AT is DOT elta DOT co DOT il> <fc DOT 000f77f3000f9130000f77f3000f8d9e DOT f914c AT bni DOT mg>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> 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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019