Re: Re: pthread_cancel() during read...
Re: Re: pthread_cancel() during read...
- Subject: Re: Re: pthread_cancel() during read...
- From: email@hidden
- Date: Tue, 17 Oct 2006 19:57:03 -0700
Hi All,
On May 30, Per Mildner offered up a small program (included below) which seemed to indicated that (even with _APPLE_C_SOURCE defined) that a 'read' call was not pthread_cancel(able). The thread ended with Matt Watson of apple being able to reproduce the problem, but no further info... I'm wondering if there is any additional info on this problem. In particular, I'm wondering if I can expect different behavior in jaguar. If so, I'll be satisfied with my very crude work-around.
For what its worth, I verified that Per's program still fails to work properly on my system...
Darwin R29Tiger-4.local 8.7.0 Darwin Kernel Version 8.7.0: Fri May 26 15:20:53 PDT 2006; root:xnu-792.6.76.obj~1/RELEASE_PPC Power Macintosh powerpc
compiled via "gcc -D_APPLE_C_SOURCE foo.c"
Thanks much,
-mike
Below is a copy of Per's original program/email...
#include <assert.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
static int exit_status = EXIT_FAILURE;
void *
func(void *arg)
{
char buf;
exit_status = EXIT_SUCCESS;
while (1)
{
ssize_t res;
fprintf(stderr, "calling read..");fflush(stderr);
res = read(STDIN_FILENO, &buf, 1);
fprintf(stderr, ".called read()==%ld\n", (long)res);fflush(stderr);
}
return NULL;
}
int
main(void)
{
pthread_t t;
void *retval;
assert(!pthread_create(&t, NULL, func, NULL));
sleep(1);
assert(!pthread_cancel(t));
assert(!pthread_join(t, &retval));
assert(PTHREAD_CANCELED == retval);
return exit_status;
}
# The first <CR> below is for passing the line to shell (all this is done in bash from within xemacs)
wormwood2:~/sicstus/sicstus4wormwood2 perm$ gcc -D_APPLE_C_SOURCE foo.c && ./a.out <CR>
calling read.. HANGS UNTIL an additional <CR> entered
wormwood2:~/sicstus/sicstus4wormwood2 perm$ gcc -D_APPLE_C_SOURCE foo.c && ./a.out <CR> <CR>
calling read...called read()==1
calling read.. HANGS HERE until an additional <CR> entered
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden