Mail Archives: cygwin/2008/09/29/10:43:49
------=_NextPart_000_0026_01C9228D.0B0463E0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
>Your test case worked fine for me with Cygwin 1.7.x. I don't have a
>copy of 1.5.x handy to test.
> >> 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.
> >I do not think that is true. As per
> ><http://www.opengroup.org/onlinepubs/009695399/functions/fork.html>,
> >RATIONALE, the penultimate paragraph, it is basically undefined
behaviour.
>
> I wrote the current version of cygwin's fork.
I also confirmed previous code worked fine with Cygwin 1.7.
But attached code hangs on Cygwin 1.7. (Actually this is what
test_3_join_in_forked_from_thread is doing)
------=_NextPart_000_0026_01C9228D.0B0463E0
Content-Type: application/octet-stream;
name="main.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="main.c"
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <assert.h>
void *thread_func_2(void* args)
{
puts("thread_func_2"); /* hang up here */
}
void *thread_func_1(void* args)
{
int ret;
pid_t pid;
puts("thread_func_1");
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 */
{
pthread_t thread;
puts("child process");
ret = pthread_create(&thread, NULL, thread_func_2, NULL);
assert(ret == 0);
ret = pthread_join(thread, NULL);
assert(ret == 0);
puts("child process end");
}
return args;
}
int main()
{
int ret;
pthread_t thread;
ret = pthread_create(&thread, NULL, thread_func_1, NULL);
assert(ret == 0);
ret = pthread_join(thread, NULL);
assert(ret == 0);
}
------=_NextPart_000_0026_01C9228D.0B0463E0
Content-Type: text/plain; charset=us-ascii
--
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/
------=_NextPart_000_0026_01C9228D.0B0463E0--
- Raw text -