Date: Wed, 14 Oct 1998 18:27:51 -0700 From: Mike Smith <mike@smith.net.au> To: Darren Whittaker <djw@sage1.sagecorp.com> Cc: Mike Smith <mike@smith.net.au>, freebsd-current@FreeBSD.ORG, john.young@openmarket.com Subject: Re: problem in 3.0 Message-ID: <199810150127.SAA00583@dingo.cdrom.com> In-Reply-To: Your message of "Wed, 14 Oct 1998 11:28:10 MDT." <Pine.SOL.3.93.981014112532.9696A-100000@sage1.sagecorp.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> The code appeared to work until I set buf[0] = '\0'; at the start of the
> loop, then only one message was displayed. Since err displays to std error
> and I have to run this program from a browers I did not see any error
> messages.
I specifically asked what the exact code below does when built as a
program and run on your system.
If setting buf[0] to 0 kills all but the first output, you should be
checking the return from fgets, as it's likely that it's not returning
anything.
> -Darren
>
> ------------------
> Darren Whittaker
> Senior Software Engineer
> Small Enterprise Group
> Open Market, Inc.
>
> On Wed, 14 Oct 1998, Mike Smith wrote:
>
> > > The fact of the matter is that date only returned output once, why did it
> > > not return output 10 times?
> >
> > No idea. I can't make it fail in that fashion here, on a range of
> > -current systems from mid-September through yesterday's snapshot.
> >
> > Does the following:
> >
> > #include <stdio.h>
> > #include <err.h>
> >
> > void main(void)
> > {
> > int i, j;
> > char buf[256];
> > FILE *p;
> >
> > for (i = 0; i < 100; i++) {
> > if ((p = popen("/bin/date", "r")) == NULL)
> > err(1, "popen");
> > fgets(buf, sizeof(buf) - 1, p);
> > printf(buf);
> > if ((pclose(p)) == -1)
> > err(1, "pclose");
> > }
> > }
> >
> > do the "right" or the "wrong" thing?
> >
> > > -Darren
> >
> > --
> > \\ 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
>
--
\\ 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199810150127.SAA00583>
