Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!uwvax!astroatc!nicmad!madnix!henning From: henning@madnix.UUCP (Mark D. Henning) Newsgroups: comp.sys.amiga.programmer Subject: child process I/O problem (source included) Keywords: help, I/O, child, parent Message-ID: <1792@madnix.UUCP> Date: 3 Apr 91 04:40:32 GMT Organization: MADNIX, operated by: ARP Software Madison WI Lines: 135 Hello. I have a rather complicated programming problem. I am not sure where it lies, but it is rather nasty. What I am trying to accomplish is to have a syncronous process place data into a temproary file, eventually receiving its input from a temporary file created by the parent process. I had originally tried to do this using the pipe device as the output stream of the child process, but I ran into a problem of the parent blocking forever, waiting for an end of file so that it's final read could be processed. This made me decide to use temp files. I use the Aztec fexecv function so that the parent waits till' the child is finished. (I used the AmigaDos Execute when working with the pipe device, as it would block anyway if its buffer overran, thus allowing the parent to slurp the output as the child delivered it.) The redefining of pr_COS worked fine without the redefining of pr_CIS. Therefore I am not forgetting any BCPL garbage (I think?) However, when I debug through the parent program, somewhere during the fexecv memory location 0000000 is written 0a000000. Future calls can cause a guru. The filter works with the equivelent function in a shell: filter tmp Therefore Either I am forgetting to set something in my process structure to reflect the new CIS, or fexecv does something fishy. Please help. This is the final routine to make GNU emacs a full port. Once this is accomplished, I can start to revamp the interface, making it more ``intuition'' friendly, and get to fixing the elusive file completion across devices bug. Thanks in advance, Mark Henning P.S. C code for examples follows the signature. -------------------------------------------------------------------------- Providing the Amiga community with GNU Emacs and related materials. UUCP: {harvard|rutgers|ucbvax}!uwvax!astroact!nicmad!madnix!aemsrc!henning {decvax|att}! INTERNET: henning@aemsrc.UUCP IF ABOVE FAILS: henning@stolaf.edu -------------------------------------------------------------------------- /************************************************ * useless filter, but good for testing purposes ************************************************/ #include main () { char c; while ((c = getchar()) != EOF){ putchar(c); putchar(c); } exit (0); } /*************************************************************************** * second program, the parent. *****************************************************************/ #include #include #include #include #include #include int child_setup(new_argv, nametem) register char **new_argv; char *nametem; { struct FileHandle *sout,*sin; struct Process *SyncProc; int fd,ok; SyncProc = (struct Process *)FindTask (0); sout = SyncProc->pr_COS; sin = SyncProc->pr_CIS; SyncProc->pr_COS = Open (nametem, MODE_NEWFILE); SyncProc->pr_CIS = Open ("wrk:syncprocess/foo", MODE_OLDFILE); ok = fexecv (new_argv[0], new_argv); Close (SyncProc->pr_COS); Close (SyncProc->pr_CIS); SyncProc->pr_COS = sout; SyncProc->pr_CIS = sin; return ok; } void main () { int fd; int nread; char buf[80]; char *args[2] = { "filter", (char *) 0 }; char *name; name = mktemp ("t:emacspipeXXXX"); if (child_setup(args, name) == -1) { fprintf(stderr,"error in child process #%d\n",errno); exit(-1); } fd = open (name , O_RDONLY ); while ((nread = read (fd, buf, sizeof buf)) >0) { write (fileno(stdout), buf, nread ); } close (fd); } -- UUCP: {harvard|rutgers|ucbvax}!uwvax!astroatc!nicmad!madnix!henning {decvax|att}!