On 11 Jul 2003, Alex Shnitman wrote:

> Hi,
>
> #include <pthread.h>
> #include <sys/types.h>
> #include <unistd.h>
> #include <stdio.h>
>
> void *thread(void* arg)
> {
>       while(1)
>               sleep(1);

Am I wrong or does sleep() halts the entire process (all the threads)?
Maybe that's the bug here.

I don't remember what is the multi-threaded alternative. Maybe
pthread_cond_timed_wait?

Regards,

        Shlomi Fish


>       return NULL;
> }
>
> int main()
> {
>       pthread_t tid;
>       int rv;
>
>       if(rv = pthread_create(&tid, NULL, thread, NULL)) {
>               printf("Can't create thread: %d\n", rv);
>               exit(1);
>       }
>
>       switch(fork()) {
>       case -1:
>               perror("fork");
>               exit(1);
>               break;
>
>       case 0:
>               printf("Sweet child in time: %d\n", getpid());
>               execlp("echo", "echo", "you'll see the light", NULL);
>               perror("execlp");
>               exit(1);
>               break;
>
>       default:
>               printf("Father\n");
>               pause();
>               break;
>       }
>
>       return 0;
> }
>
>
>
> --
> Alex Shnitman <[EMAIL PROTECTED]>
> http://www.hectic.net/ UIN 188956
> PGP 0xEC5D619D / E1 F2 7B 6C A0 31 80 2863 B8 02 BA 65 C7 8B BA
>
> =================================================================
> To unsubscribe, send mail to [EMAIL PROTECTED] with
> the word "unsubscribe" in the message body, e.g., run the command
> echo unsubscribe | mail [EMAIL PROTECTED]
>



----------------------------------------------------------------------
Shlomi Fish        [EMAIL PROTECTED]
Home Page:         http://t2.technion.ac.il/~shlomif/

There's no point in keeping an idea to yourself since there's a 10 to 1
chance that somebody already has it and will share it before you.


=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to