www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2025/06/17/08:54:44

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 55HCsiXA408397
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 55HCsiXA408397
X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DA4F63843B6E
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DA4F63843B6E
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750164854; cv=none;
b=SoWKMFjJo+W1gLa4YINWJhZfO85885FRdQefLKfk7NuI0X70dC0QPZ3n7I7zubzcuC0mrY7QP7yX9SXOHcVYlf80u5NxLMaGb8ejEdYdJje05E1dMhhHhAH7UUW9x10XTTLAAHmjkTnehfDVDqA8LWjJ8NQ3Nyseg84h7krupL8=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1750164854; c=relaxed/simple;
bh=fhG5mkxh531nujusQ+6/DKCYWyk3A1c3wxL6heqj7no=;
h=Date:From:To:Subject:Message-Id:Mime-Version:DKIM-Signature;
b=ODjt048+3V8c14Ae7Z5OumBqVa9S0uZQDyOKKl0hQIbubT7W7rchZ/jhAHhkHpG5AQxh6Mhse0dIpg3e/+qQqrWEX/73Y1dHSbSvQ46Vwpvwnh1zV34D5dCosUDxEgKUKO2aWa8QKMk2R2tYEd/86Dk8mwvII1/5K78RxlkreYY=
ARC-Authentication-Results: i=1; server2.sourceware.org
Date: Tue, 17 Jun 2025 21:54:11 +0900
To: cygwin AT cygwin DOT com
Subject: Calling system() in multi-threads.
Message-Id: <20250617215411.ebf69d1c18b55191a1b76c01@nifty.ne.jp>
X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
Mime-Version: 1.0
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Takashi Yano via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>

This is a multi-part message in MIME format.

--Multipart=_Tue__17_Jun_2025_21_54_11_+0900_QbbixUt3agTsYghg
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

Hi,

If system() is called in parallel in threads, system()
fails with exit code 127.

Just compile pthread_system.c attached and run.

I believe system() is multi-thread safe so the STC
should work.

-- 
Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>

--Multipart=_Tue__17_Jun_2025_21_54_11_+0900_QbbixUt3agTsYghg
Content-Type: text/x-csrc;
 name="pthread_system.c"
Content-Disposition: attachment;
 filename="pthread_system.c"
Content-Transfer-Encoding: 7bit

#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>

void *func(void *arg)
{
	printf("%d\n", system("/usr/bin/echo AAAAAAAAAAAAAAAAAAAA"));
	return NULL;
}

#define N 10
int main()
{
	pthread_t th[N];
	for (int i=0; i<N; i++) {
		pthread_create(&th[i], NULL, func, NULL);
	}
	for (int i=0; i<N; i++) {
		pthread_join(th[i], NULL);
	}
	return 0;
}

--Multipart=_Tue__17_Jun_2025_21_54_11_+0900_QbbixUt3agTsYghg
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

--Multipart=_Tue__17_Jun_2025_21_54_11_+0900_QbbixUt3agTsYghg--

- Raw text -


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