Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!snorkelwacker!tut.cis.ohio-state.edu!mailrus!uflorida!novavax!hcx1!brad From: brad@SSD.CSD.HARRIS.COM (Brad Appleton) Newsgroups: comp.lang.c Subject: Re: Controlling stdin and stdouts of other executables Message-ID: <4077@hcx1.SSD.CSD.HARRIS.COM> Date: 6 May 90 18:48:26 GMT References: <10765@shlump.nac.dec.com> <3967@hcx1.SSD.CSD.HARRIS.COM> <6418@star.cs.vu.nl> Sender: news@hcx1.SSD.CSD.HARRIS.COM Organization: Harris Computer Systems, Fort Lauderdale, FL Lines: 34 In article <6418@star.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes: > >It's *WRONG* to close an arbitrary program's standard streams! The program being called is NOT arbitrary, the coder knows which command is to be called. >Suppose the program checks the return value of printf() - if stdout is >closed, printf() will return EOF, so the program might decide something >is terribly wrong, and terminate! But output will still have been (successfully) ignored :-) >You don't want to close the standard streams, you want to connect them >to /dev/null, quite a difference! Agreed! I personally would have connected output to /dev/null myself. Perhaps I should have posted a solution using "dev/null" instead but I was trying to give an easy example (which works just fine on my System BTW). You are right in that I probably should have used /dev/null. >Bonus: the `0' in the execlp() call should be `(char *) 0'; grrrr, when >do people ever learn? :-( GRRRRRR yourself! I used it the way it was documented for my system!!!! I originally had used NULL (which is preferred over (char *) 0) instead of 0 but My reference text used 0 (not (char * 0))! My system may be slightly different than yours, but I did use the proper type according to my FM. (Of course, it could be a problem in the FM :-) -=-=-=-=-=-=-=-=-=-=-= "And miles to go before I sleep." =-=-=-=-=-=-=-=-=-=-=- Brad Appleton Harris Computer Systems brad@ssd.csd.harris.com (305) 973-5360 Fort Lauderdale, FL USA {uunet,novavax}!hcx1!brad -=-=-=-=-=-=-=-=-=-= Disclaimer: I said it, not my company! -=-=-=-=-=-=-=-=-=-