EXEC fails. waitpid() No child processes

EXEC fails. waitpid() No child processes

Post by Tom Rudni » Thu, 21 Jul 1994 08:23:42



I have been unable to get an http daemon to correctly call cgi-bin
scripts on AT&T UNIX Sys V 3.2.

After much trial and error, I can't solve the following problem and
need your help.

synopsis:

httpd forks, dups the file descriptors, then execle's the specified cgi-bin
program name. In this case "tom".

"tom" forks, execl's "/bin/date" then dies. No output comes from the final
program.  "tom" dies on the waitpid(), saying "No child processes".

I can execle "tom" directly, and everything works as expected. (fine) It's
just when this sequence is executed from within httpd it all fails. Is there
Has anyone seen this behavior before?

It acts almost as if it can't write to stdout. I verified that the close
on exec flags aren't set by httpd.

I have included the small sources below to verify that I'm not insane.

/* tom.c */
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>

static char contents[]="Content-type: text/plain\n";

extern int errno;

int main(argc, argv, envp)
int argc;
char *argv[];
char *envp[];
{
        static short pid;
        int stat_loc=0;
        int retcode;

        puts(contents);

        if((pid=fork())==0)
                execl("/bin/date", "",NULL);

        if(waitpid(pid, &stat_loc, 0)<0)
        {       perror("waitpid() failed");
                fprintf(stderr,"stat_loc: %X\n",stat_loc);
                exit(errno);
        }

        exit(0);

Quote:}

/* calltom.c */
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>

extern int fork();
extern int wait();
extern int errno;

int main(argc, argv, envp)
int argc;
char *argv[];
char *envp[];
{
        static short pid;
        int stat_loc=0;
        int retcode;

        if((pid=fork())==0)
        {      
                execle("/usr/local/httpd/cgi-bin/tom", (char *)0, envp);
        }

        if(waitpid(pid, &stat_loc, 0)<0)
        {       perror("waitpid() failed");
                fprintf(stderr,"stat_loc: %X\n",stat_loc);
                exit(errno);
        }

        exit(0);

Quote:}

---------------------------------------
-Tom
--
----------------/------------------------------------------------------------


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-|TMBG|-| Land's where we know the boat is found.
 
 
 

1. smail failed to reap child process: No child processes

Offen I receive messages with error:

From MAILER-DAEMON Wed Dec 20 17:55:59 1995
To: postmaster
Subject: mail failed, sending to postmaster

|------------------------- Message log follows: -------------------------|

|------------------------- Failed addresses follow: ---------------------|

|------------------------- Message text follows: ------------------------|
Received: by fishwar.koenig.su; Wed, 20 Dec 95 17:55 GMT+0200
[...]

But mail successfully delivered to destination address.

What's wrong?

Alexander Feldman

2. Rotating logs

3. waitpid for a non child process

4. USB on a Lombard with R4?

5. how to kill a child process that runs other children processes

6. fix-cua on redhat

7. Getting a child and child's child process-id

8. Yggdrasil summer '94, TMC-850 SCSI

9. How to find out if the child process has done exec()

10. Help with SMAIL - offen got meaasage about failed to reap child process

11. system() vs. fork/exec/waitpid