On Sun, Sep 28, 2008 at 09:32:39AM +0200, V??clav Haisman wrote: >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA256 > >Hirokazu Yamamoto wrote, On 28.9.2008 4:16: >> # I've post mail, but it didn't show up in >> http://www.nabble.com/Cygwin-f12165.html. >> # Maybe it was not good to attach a file. So try again... >> >> I'm not familiar with pthread & fork, but I think following code should not >> crash. Is this expected behavior? >> >> #include <stdio.h> >> #include <stdlib.h> >> #include <pthread.h> >> #include <assert.h> >> >> void *thread_func(void* args) >> { >> int ret; >> pid_t pid; >> pthread_t thread; >> >> puts("thread_func"); >> >> pid = fork(); >> >> assert(pid != (pid_t)-1); >> >> if (pid != 0) /* parent process */ >> { >> int status; >> >> printf("parent process (child pid = %d)\n", pid); >> >> waitpid(pid, &status, 0); >> >> puts("parent process end"); >> } >> else /* child process */ >> { >> puts("child process"); /* crash here */ >I think this is not allowed in here. You can only do async-signal-safe >stuff in the child. IO is AFAIK not in that category. Basically, the >only thing you can safely do in the child process is to call exec().
I don't see any reason why this shouldn't be allowed. You should be able to do anything you want in a child process. cgf -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/