delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/02/06/12:58:00

Delivered-To: listarch-cygwin AT sourceware DOT cygnus DOT com
Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
To: gnu-win32 AT cygnus DOT com
Subject: Problem with socketpair/fork/dup2/fdopen b20
Organization: Felix's Inc.
X-Phone: (33) 05 34 25 00 85
X-Url: http://worldserver.oleane.com/felix
X-Face: (2-K{U0yXR]I/Wwmk6A:{w{-^>b-<Zkx1=P*t9[N?DM+I-Ld(&6$M&dhf DOT Frdi8A_cb AT 6n:
0L|^Q.zjR/+!8]aG@<FtLipq>:4lQ8n/k$/Y_v?O`S?K(+bMCG%=6hCaV}Q<4{P5GV!7Sw7:JCHk$X
h]-U-bd5W*^ZJ#3+SS-mes|KouqUZr]&HMK/39.p"zAg-%d}T#!t2h1F1M}|%M_>#6G31b%6zi*0\m
M;$Lp=U*0u'$F*rf+rl|;k,-'bup17^]"Hlv=5S^mY*w6_C`@wdg'YJ^AylxPF3w~28Q52A\*=s0%3
0s?n*<I]uSKG
From: Francois Felix Ingrand <felix AT dial DOT oleane DOT com>
Date: 06 Feb 1999 13:56:28 +0100
Message-ID: <8690ebsnb7.fsf@dial.oleane.com>
User-Agent: Gnus/5.070071 (Pterodactyl Gnus v0.71) XEmacs/20.3 (Vatican City)
MIME-Version: 1.0
Lines: 44

I cannot get this to work.

fdopen returns NULL and perror a bad file descriptor... which would suggest
that dup2 did not duplicate stdout in sp[1]...

It work under Solaris and other Unices...

void call_propice_cat(char *log_file)
{
     int pid, sp[2];

     if (socketpair(AF_UNIX, SOCK_STREAM, 0, sp) < 0) {
	  perror("call_propice: socketpair");
	  exit(1);
     }
     fcntl(sp[1], F_SETFD, 1);      /* this is to avoid that the ns will be dup when we fork */
     
     if ((pid = fork()) < 0) {
	  perror("fork");
	  exit(1);
     }

     if (pid) {			/* The father */
	  close(sp[0]);		/* Close one side */
	  fcntl(sp[1], F_SETFL, FNDELAY); /* I am not sure this is required... */
	  if (dup2(sp[1],1) < 0)
	       perror("call_propice_cat:dup2");	/* Get stdout plug on sp[1] */
	  /* dup2(sp[1],2);    Get stderr plug on sp[1] */

	  propicefp = (FILE *)fdopen(sp[1], "r+");
	  if (! propicefp) 
	       perror("call_propice_cat:fdopen");	/* Get stdout plug on
							   sp[1] */
	  setbuf(propicefp, NULL);

	  propiceInputId = XtAppAddInput(app_context, sp[1], (XtPointer)XtInputReadMask, read_propice, NULL);
     } else {			/* The child */

-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"J'en ai cauchemarde... Microsoft l'a fait."
Professional: http://www.laas.fr/~felix         mailto:felix AT laas DOT fr
Personal: http://worldserver.oleane.com/felix   mailto:felix AT dial DOT oleane DOT com


--   
Want to unsubscribe from this list?                             
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019