This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
dup() and dup2()
- To: gnu-win32 at cygnus dot com
- Subject: dup() and dup2()
- From: Aldo Mazzilli <aldo dot mazzilli at inria dot fr>
- Date: Tue, 08 Dec 1998 12:56:35 +0100
- Organization: INRIA
I have some problems with building a tool which invoke fork(), pipe()
and dup() unix-commands.
It works correctly on my Unix platform (Solaris) but when I port the
source under Win32, redirections fail.
Can someone tell me why this problem occurs ...
Here is a source portion :
============================
/* Create the pipes */
pipe(pipe1) ;
pipe(pipe2) ;
parent = fork() ;
switch (parent)
{
case -1:
printf("fork() error \n");
exit(1) ;
break ;
case 0:
process = "children";
dup2(pipe2[0],STDIN_FILENO);
dup2(pipe1[1],STDOUT_FILENO) ;
close(pipe1[0]) ;
close(pipe1[1]) ;
close(pipe2[0]) ;
close(pipe2[1]) ;
system (command1) ;
fflush(stdout) ;
exit(0);
break ;
default:
process = "parent" ;
dup2(pipe1[0],STDIN_FILENO) ;
dup2(pipe2[1],STDOUT_FILENO) ;
close(pipe1[0]) ;
close(pipe1[1]) ;
close(pipe2[0]) ;
close(pipe2[1]) ;
system ("sh") ;
exit(0);
}
====================================
IPC doesn't work between "command1" and "sh"
--
=======================================================================
,',',',',',',' Aldo MAZZILLI | INRIA Rhone-Alpes |
,',',',',',',' aldo.mazzilli@inrialpes.fr| 655, avenue de l'Europe |
,',',',',',',' Tel : 04 76 61 53 91 | 38330 Montbonnot St Martin |
,',',',',',',' Fax : 04 76 61 52 52 | FRANCE |
,',' *** Site WEB : http://www.inrialpes.fr/vasy/people/Aldo.Mazzilli |
=======================================================================
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".