popen()

RouE cstaqgx at cu.warwick.ac.uk
Sun Mar 10 05:14:59 AEST 1991


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);
    }

This works fine if I run this as is, but if I do


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?

thanks,

RouX
--
Jason L Saunders [ alias RouXiaN (RouX) - ex-RouE, now XiaN ]
email: cstaqgx at uk.ac.warwick.cu  or  roue at uk.ac.warwick.cs
snail: Mathematics Institute, University of Warwick, Coventry CV4 7AL, UK
			"You can't learn to swim in the lake of fire"
-- 
Jason L Saunders [ alias RouXiaN (RouX) - ex-RouE, now XiaN ]
email: cstaqgx at uk.ac.warwick.cu  or  roue at uk.ac.warwick.cs
snail: Mathematics Institute, University of Warwick, Coventry CV4 7AL, UK
			"You can't learn to swim in the lake of fire"



More information about the Comp.unix.programmer mailing list