popen()

Kartik Subbarao subbarao at phoenix.Princeton.EDU
Tue Mar 12 01:41:45 AEST 1991


In article <CSTAQGX.91Mar9191459 at lily.warwick.ac.uk> cstaqgx at 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 at phoenix.Princeton.EDU -| Internet
kartik at silvertone.Princeton.EDU (NeXT mail)  
SUBBARAO at PUCC.BITNET			          - Bitnet



More information about the Comp.unix.programmer mailing list