delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:message-id:from:to:cc:subject:date; q=dns; s= | |
default; b=FRI1QEos+xu0u6JGxDVMLauRs6mJueUz5S0nG/2Gr7V1Yxtjs/dRG | |
8iSj6JojuZLeHwy+4RsFX4ZbRQUaAU+nnqHbeJtRmgNC+5OvLEdmnfMl2ds7q0ii | |
g6UcVH/sKNXC9Pip8o3oJKy2eFZku9yFTe8ARCEND8jzHT7JCgeKVI= | |
DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:message-id:from:to:cc:subject:date; s=default; | |
bh=OmUo0TCaQdan63PxN21v3W0hUW4=; b=ljY86DsUGXDorIv9xShvPJ03gZzN | |
SKY9xa1sgj7JQjzecSRQMeC5nlmquHfUN9zuEN4nLXVrjHDBnmgQ8dhElP3Fpqg1 | |
4lzMLhuhQyN5GHgSn9kyCKpK/eBOtQiWf2PtpjYYPgoyD0uGYSKSN0x9rRqwTG5a | |
qj6edjcTbFP+V9k= | |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Authentication-Results: | sourceware.org; auth=none |
X-Virus-Found: | No |
X-Spam-SWARE-Status: | Yes, score=5.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 |
X-HELO: | nm13-vm9.access.bullet.mail.gq1.yahoo.com |
Message-ID: | <831845.98759.bm@smtp116.sbc.mail.ne1.yahoo.com> |
X-Yahoo-SMTP: | BDVluRmswBBpb4.UU1_zlPhs_ysfXcBVjBNXyWpyS_6pPgE- |
X-Rocket-Received: | from solabel10.tnolan.com (tednolan AT 74 DOT 243 DOT 198 DOT 131 with plain [98.138.84.52]) by smtp116.sbc.mail.ne1.yahoo.com with SMTP; 13 Jan 2014 16:30:56 +0000 UTC |
From: | tednolan AT bellsouth DOT net |
To: | cygwin AT cygwin DOT com |
cc: | tednolan AT bellsouth DOT net |
Subject: | fork() + file descriptor bug in 1.7.27(0.271/5/3) 2013-12-09 11:54 |
Date: | Mon, 13 Jan 2014 11:06:12 -0500 |
X-IsSubscribed: | yes |
Hello, I'm running: CYGWIN_NT-6.1 prog5 1.7.27(0.271/5/3) 2013-12-09 11:54 x86_64 Cygwin gcc (GCC) 4.8.2 on a 64 bit Win7 system. I have just run into an odd bug, which I have boiled down into the program below (which started as a mod to tiff2ps). If you compile this program: =========================CUT HERE============= #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/wait.h> int main(int argc, char **argv) { FILE *fp; char buf[4096]; char infile[4096]; char outfile[4096]; int i = 0; int running_children = 0; int child_limit = 20; int wait_status; if (argc == 1) { fp = stdin; } else if (argc == 2) { fp = fopen(argv[1], "r"); if (!fp) { fprintf(stderr, "Can't open input list %s\n", argv[1]); exit(1); } } else { fprintf(stderr, "Usage: multi_tiff2ps [spec_file]\n"); exit(1); } while( fgets(buf, sizeof(buf), fp) ) { ++i; if(sscanf(buf, "%s %s", infile, outfile) != 2) { fprintf(stderr, "Malformed spec line %d (%s)\n", i, buf); continue; } //fprintf(stderr, "(%s) (%s) %d %ld\n", infile, // outfile, i, ftell(fp)); fprintf(stderr, "Running %d\n", running_children); if (running_children >= child_limit) { fprintf(stderr, "Initial wait\n"); wait(&wait_status); --running_children; } switch (fork()) { /* error */ case -1: fprintf(stderr, "Can't fork new tiff2ps process!\n"); exit(1); break; /* child */ case 0: fprintf(stderr, "child\n"); fflush(stderr); exit(0); break; /* parent */ default: ++running_children; break; } } for(i = 0; i < running_children; i++) { fprintf(stderr, "Final wait\n"); wait(&wait_status); } exit(0); } =========================End code============= and run it with this data: 00.tif 00.eps 01.tif 01.eps 02.tif 02.eps It will run forever. However, if you uncomment the fprintf with the ftell(), it runs as expected. It works correctly on linux. Anyone seen this before? Is there a fix? Thanks! Ted Nolan -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |