Path: utzoo!attcan!uunet!husc6!cmcl2!adm!xadmx!dsg@MBUNIX.B.MITRE.ORG From: dsg@MBUNIX.B.MITRE.ORG (Dave Goldberg) Newsgroups: comp.unix.questions Subject: Timing strangeness? Message-ID: <16826@adm.ARPA> Date: 16 Aug 88 15:03:37 GMT Sender: news@adm.ARPA Lines: 48 I don't know if this is a C or Unix question, so I apologize if this isn't the appropriate group. Anyway: We're implementing a distributed printing facility using ethernet connected Imagen printers. In order to allow us to have local burst pages, I wrote a small program to build and send a banner page, and then send the job. The strangeness is that even though the sequence of the program indicated that the banner page should be printed first, it was coming out after the job. Here's a bit of the code: char *banner, c; FILE *fb,*pg; banner = buildbanner(); /* * buildbanner builds a temp file with the * postscript in it and returns the file's path */ if ((fb = fopen(banner,"r")) != NULL) { while ((c = getc(fb)) != EOF) putchar(c); fclose(fb); unlink(banner); } pg = popen("/usr/local/lib/ps/pstext","w"); /* No flames, in the real I check for errors */ while ((c = getchar()) != EOF) putc(c,pg); pclose(pg); Now it seems to me that the banner page should be printed first, but it isn't. To fix the problem, I fork(2)ed a process to print the banner page and wait(2) for it before sending the rest of the job. This now works as I'd expect. But the question remains: why do I have to? Please email responses as I don't want to clutter the net, especially if it's a real simple thing I've missed in the manual. If there's any interest I'll summarize. Thanks much, -dave -------------------------------------------------------------------------- Dave Goldberg ARPA: dsg@mitre-bedford.arpa The Mitre Corporation UUCP: linus!mbunix!dsg MS B015 Bedford, MA 01730 617-271-2460