Xref: utzoo comp.unix.internals:635 comp.unix.programmer:229 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!linac!midway!mimsy!mojo!news From: ananth@eng.umd.edu (Sekhar C. Ananthakrishnan) Newsgroups: comp.unix.internals,comp.unix.programmer Subject: Help needed in interprocess communication problem... Message-ID: <1990Oct12.124438.22499@eng.umd.edu> Date: 12 Oct 90 12:44:38 GMT Sender: news@eng.umd.edu (The News System) Organization: College of Engineering, Maryversity of Uniland, College Park Lines: 43 Hi Netters, I have a problem with a piece of code I am trying to write and I was not able to get any ideas from books. So, I am posting it hoping that someone could help me. I have a "client" program which has a piece of code similar to the following..... . . printf("Enter value for X"); scanf("%d",&X); printf("Enter value for Y"); scanf("%d",&Y); printf("The final value is %d\n", X+Y); . . I want to write another program say "handler", which forks client as a child process, read the printf statements and supply values for the scanf statements using "read" and "write". I do not want to change the printf and scanf statements in the client to "read" and "write". How do I synchronize the exchange between the shell and the client? I want the handler program to do the following. read(0, buff, 256); /* at this point buff should contain "Enter value for X". */ /* parse "Enter value for X" and give a value for X*/ write(1,reply,strlen(reply)); /* where reply is a buffer containing value for X)*/ read(0,buff,256) and so on. Could somebody tell me how it could be done? If there is an easy solution, I would appreciate if somebody can E-mail me on how it could be done. Thanks in advance. shyam ananth@mordor.eng.umd.edu