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.y...@nifty.ne.jp>
#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;
}
-- 
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

Reply via email to