Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!zaphod.mps.ohio-state.edu!rpi!bu.edu!snorkelwacker!bloom-beacon!iris49.UUCP!pete From: pete@iris49.UUCP (Pete Ware) Newsgroups: comp.windows.x Subject: Re: XtAppAddInput and pipes Message-ID: <9010121709.AA05284@iris49.biosym.com> Date: 12 Oct 90 17:09:31 GMT References: <2068@cybaswan.UUCP> Sender: root@athena.mit.edu (Wizard A. Root) Organization: The Internet Lines: 36 eejames> My questions are: eejames> 1) Why does the program work fine with the keyboard attached eejames> to stdin, but not with a pipe attched? The program providing input is probably exiting which closes the pipe. eejames> 2) Is there a simple fix? Yes, change your function, input_fn() to something like: void input_fn(client_data, source, id) caddr_t client_data; int *source; XtInputId *id; { int time; if (scanf("%d",&time) == EOF) { XtRemoveInput (*id); return; } printf("time is %d\n",time); /* other processing etc */ } - You might also consider using using gets() so you don't block if the user just enters a return (scanf keeps looking for input). - You might want to use the client_data to pass in the actual file pointer so it can work for any source of input. - You might want to close the file pointer when EOF is reached. --pete Pete Ware / Biosym / San Diego CA / (619) 546-5532 uucp: scripps.edu!bioc1!pete Internet: bioc1!pete@scripps.edu