Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!chaph.usc.edu!alcor.usc.edu!jeenglis From: jeenglis@alcor.usc.edu (Joe English) Newsgroups: comp.windows.x Subject: Re: io redirect of xterm -e cmd Message-ID: <9005@chaph.usc.edu> Date: 9 Apr 90 21:27:03 GMT References: <3222@castle.ed.ac.uk> Sender: news@chaph.usc.edu Organization: University of Southern California, Los Angeles, CA Lines: 32 kgg@lfcs.ed.ac.uk (Kees Goossens) writes: >I would like to redirect some of the output of a program I usually run as >xterm -e program into a separate X window. >Why doesn't the following work? > >{ > FILE *f; > f = open ( "/tmp/zap", "w" ); > system "/usr/local/bin/X11R4/xterm -e cat /tmp/zap"; > > ... here I use fprintf(f,...); for writing to that X window > and fprintf(stdout,...); for writing to the X window in > which the program was started ... > > fclose(f); >} The problem is, cat only reads to the end of the file and then exits. If you use 'tail -f' instead of 'cat' in the call to system() it will work, but you have to get the pid of the tail or xterm process and kill it or else it will never exit. A better solution would be to use 'f=popen("xterm -e cat")' instead of a temporary file. --Joe English jeenglis@nunki.usc.edu