Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!samsung!emory!gatech!udel!princeton!phoenix.Princeton.EDU!subbarao From: subbarao@phoenix.Princeton.EDU (Kartik Subbarao) Newsgroups: comp.unix.programmer Subject: Re: popen() Message-ID: <7051@idunno.Princeton.EDU> Date: 11 Mar 91 15:41:45 GMT References: Sender: news@idunno.Princeton.EDU Distribution: comp Lines: 69 In article cstaqgx@cu.warwick.ac.uk (RouE) writes: >I'm having trouble with popen(). In particular I am trying to do > >FILE *pp; >char lineread[80]; >pp = popen("rlogin lily","r+"); >while (1) > while (!feof(pp)) { > fgets(lineread,80,pp); > fprintf(stderr,lineread); > } >main() { > >if (fork()) exit(0); >signal(SIGHUP,SIG_IGN); >signal(SIGQUIT,SIG_IGN); >signal(SIGINT,SIG_IGN); >. >. >. > >at the beginning, then I get a seg. fault when fgets tries to read from the >pipe. I've changed the command to "cat /usr/dict/words" and it works fine in >the background, so I reckon it's something to do with doing a pipe to rlogin. > >Does anyone have any idea what is wrong, and what can be done about it? This seems like a weird way to do things....In the first case, the stuff you subsequently type to your tty gets sent to the rlogin process, which may not be what you want. As for forking and putting it in the background, on the system that I'm on you get a read error from the terminal, and rlogin closes the connection. It seems like you're confusing things a lot. If all you want is output from the rlogin session recorded, then 'script rlogin lily', or something similar is all you need. If you said exactly what you wanted to do, then I'm most certain that there could be a nicer way to do it. -Kartik s e r v e r l i n e s i n c l u d e d . -- internet# find . -name core -exec cat {} \; |& tee /dev/tty* subbarao@phoenix.Princeton.EDU -| Internet kartik@silvertone.Princeton.EDU (NeXT mail) SUBBARAO@PUCC.BITNET - Bitnet