From owner-freebsd-current Wed Oct 14 07:05:51 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id HAA26494 for freebsd-current-outgoing; Wed, 14 Oct 1998 07:05:51 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from sage1.sagecorp.com ([204.250.198.2]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id HAA26489 for ; Wed, 14 Oct 1998 07:05:43 -0700 (PDT) (envelope-from djw@sage1.sagecorp.com) Received: from localhost (djw@localhost) by sage1.sagecorp.com (8.7.5/8.7.3) with SMTP id IAA08735; Wed, 14 Oct 1998 08:12:04 -0600 (MDT) Date: Wed, 14 Oct 1998 08:12:03 -0600 (MDT) From: Darren Whittaker To: Mike Smith cc: freebsd-current@FreeBSD.ORG, john.young@openmarket.com Subject: Re: problem in 3.0 In-Reply-To: <199810080530.WAA01135@dingo.cdrom.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Thank you for your email. I have taken your code and modified it to run as a cgi: #include #include #include int main(int argc, char *argv[]) { int i, j; char buf[256]; FILE *p; /* output the head */ printf("Content-type: text/html\n"); fflush(stdout); printf("\nTESTING"); printf("

TESTING


\n"); printf("

\n");
  fflush(stdout);

/* loop using popen */
  for (i = 0; i < 10; i++)
  {
     buf[0] = '\0';
     if ((p = popen("/bin/date", "r")) == NULL)
     {
       printf("popen error: %s\n",strerror(errno));
       continue;
     }
     fgets(buf, sizeof(buf) - 1, p);
     printf(buf);

     if ((j = pclose(p)) != 0)
       printf("pclose error: %s [%d]\n",strerror(j),j);
  }

/* output the tail */
  fflush(stdout);
  printf("

Copyright © 1998 Open Market, Inc. All Rights Reserved.\n"); printf("
\n"); fflush(stdout); } Here is some of the output when I run it from the web browser: Wed Oct 14 07:00:13 PDT 1998 pclose error: No child processes [10] pclose error: No child processes [10] pclose error: No child processes [10] pclose error: No child processes [10] pclose error: No child processes [10] pclose error: No child processes [10] pclose error: No child processes [10] pclose error: No child processes [10] pclose error: No child processes [10] What do you think the problem might be? -Darren ------------------ Darren Whittaker Senior Software Engineer Small Enterprise Group Open Market, Inc. On Wed, 7 Oct 1998, Mike Smith wrote: > > We have found a problem with popen. The first popen is executed just fine > > with a good pclose. The second popen appears to work (though nothing > > happens) and the pclose returns a 138. This also applies to the system > > call. The first one works but any after sustem call after the first > > one fails. We even forked the process but in the child only the first > > popen work. > > I'm not sure that I can follow your problem here. Have you reduced the > program to its simplest form, eg: > > dingo:/tmp>cat p.c > #include > #include > > void main(void) > { > int i, j; > char buf[256]; > FILE *p; > > for (i = 0; i < 10; i++) { > if ((p = popen("/bin/date", "r")) == NULL) > err(1, "popen"); > fgets(buf, sizeof(buf) - 1, p); > printf(buf); > if ((j = pclose(p)) != 0) > errx(1, "pclose %d", j); > } > } > dingo:/tmp>gcc -o p p.c > dingo:/tmp>./p > Wed Oct 7 22:28:04 PDT 1998 > Wed Oct 7 22:28:04 PDT 1998 > Wed Oct 7 22:28:04 PDT 1998 > Wed Oct 7 22:28:04 PDT 1998 > Wed Oct 7 22:28:04 PDT 1998 > Wed Oct 7 22:28:04 PDT 1998 > Wed Oct 7 22:28:04 PDT 1998 > Wed Oct 7 22:28:04 PDT 1998 > Wed Oct 7 22:28:04 PDT 1998 > Wed Oct 7 22:28:04 PDT 1998 > dingo:/tmp>uname -a > FreeBSD dingo.cdrom.com 3.0-CURRENT FreeBSD 3.0-CURRENT #2: Wed Sep 16 16:38:28 PDT 1998 mike@dingo.cdrom.com:/local0/src/sys/compile/DINGO i386 > > What do you mean by "this also applies to the system call"? Which > system call? > > > Now our program is running as a cgi under Apache and works on your 2.x > > versions just fine. > > I'm afraid you're going to have to supply some more detail before we > can help you further here. > -- > \\ Sometimes you're ahead, \\ Mike Smith > \\ sometimes you're behind. \\ mike@smith.net.au > \\ The race is long, and in the \\ msmith@freebsd.org > \\ end it's only with yourself. \\ msmith@cdrom.com > > > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message