Xref: utzoo comp.lang.c:26528 comp.sys.ibm.pc.programmer:232 Path: utzoo!utgpu!jarvis.csri.toronto.edu!helios.physics.utoronto.ca!ists!yunexus!maccs!cs4g6ag From: cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) Newsgroups: comp.lang.c,comp.sys.ibm.pc.programmer Subject: Re: popen() Message-ID: <25F00B67.17161@maccs.dcss.mcmaster.ca> Date: 3 Mar 90 18:22:31 GMT References: <1503@loria.crin.fr> Reply-To: cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) Organization: McMaster University, Hamilton, Ontario Lines: 43 In article <1503@loria.crin.fr> anigbogu@loria.crin.fr (Julian Anigbogu) writes: $Can some kind soul point me to where I can get a PC implementation of $the Unix C popen() /* for handle to a pipe */. I manipulate huge $rasterfiles(from a scanner) on a Sun and I adopted the policy of $compressing all files to save disk space. I open them with $popen("uncompress -c filename","r") so that they remain compressed on $disk. $ I now need to port the programs to DOS and to my chagrin my regular $compiler doesn't implement a pipe open. This isn't a problem with your compiler ... it's just that Unix is a multi-tasking operating system which can run one program and have its output piped directly into another program, while DOS is single-tasking and cannot do this. DOS's idea of a pipe is as follows: -run program 1 with its stdout redirected to some file -run program 2 with its stdin redirected from that file -delete the temporary file and the only part of DOS that has any idea of how to do a pipe is the command interpreter in any case. You'll have to implement it yourself by doing the same sort of thing yourself: write a function popen that does: -come up with a temporary file name (there should be a call in your library to do this; it's a standard DOS function in DOS 3 and up. -spawn or exec or system your uncompress utility with redirection of stdout (how you handle this depends on which call you use) -fopen the temporary file and return that handle and a corresponding close that does: -close the file -delete the temporary file And, of course, this will take up disk space while your program is running. -- Stephen M. Dunn cs4g6ag@maccs.dcss.mcmaster.ca = "\nI'm only an undergraduate!!!\n"; **************************************************************************** I Think I'm Going Bald - Caress of Steel, Rush