Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin-developers AT sources DOT redhat DOT com Date: Tue, 24 Jul 2001 15:46:32 +0400 From: egor duda X-Mailer: The Bat! (v1.53 RC/4) Reply-To: egor duda Organization: deo X-Priority: 3 (Normal) Message-ID: <9715860566.20010724154632@logos-m.ru> To: cygwin-developers AT cygwin DOT com Subject: close-on-exec handles are left open by exec parent MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi! there was bug reports about "expect> spawn ping" not returning to expect prompt. Here's the simple testcase and analysis: #include #include int main (int argc, char** argv) { int x[2]; char a; int ret, pid; if (pipe (x) < 0) { perror ("pipe"); return 1; } pid = fork (); switch (pid) { case -1: perror ("fork"); return 1; case 0: close (x[0]); fcntl (x[1], F_SETFD, 1); execlp ("ping.exe", "ping.exe", "-t", "cygwin.com", NULL); default: close (x[1]); ret = read (x[0], &a, sizeof (a)); if (ret < 0) { perror ("read"); return 1; } return 0; } } test.exe create pipe and forks. when write end of the pipe is marked as close-on-exec, we DuplicateHandle () appropriately. but forked instance left running after execlp () is performed, and it doesn't close it's own copy of pipe handle. so read () blocks forever. i can see 2 ways to fix it. We can either always perform dtable::fixup_before_exec() and close handles marked as close-on-exec there, or always close all handles when exec child is started and exec parent cycles waiting for its child to exit. egor. mailto:deo AT logos-m DOT ru icq 5165414 fidonet 2:5020/496.19