… | |
… | |
649 | 0x2d02ef8dL |
649 | 0x2d02ef8dL |
650 | }; |
650 | }; |
651 | |
651 | |
652 | void thread::start (void *(*start_routine)(void *), void *arg) |
652 | void thread::start (void *(*start_routine)(void *), void *arg) |
653 | { |
653 | { |
|
|
654 | pthread_attr_t attr; |
|
|
655 | |
|
|
656 | pthread_attr_init (&attr); |
|
|
657 | pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); |
|
|
658 | pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN < sizeof (long) * 4096 |
|
|
659 | ? sizeof (long) * 4096 : PTHREAD_STACK_MIN); |
|
|
660 | #ifdef PTHREAD_SCOPE_PROCESS |
|
|
661 | pthread_attr_setscope (&attr, PTHREAD_SCOPE_PROCESS); |
|
|
662 | #endif |
|
|
663 | |
654 | sigset_t fullsigset, oldsigset; |
664 | sigset_t fullsigset, oldsigset; |
655 | sigfillset (&fullsigset); |
665 | sigfillset (&fullsigset); |
656 | |
666 | |
657 | pthread_sigmask (SIG_SETMASK, &fullsigset, &oldsigset); |
667 | pthread_sigmask (SIG_SETMASK, &fullsigset, &oldsigset); |
658 | |
668 | |
659 | if (pthread_create (&id, 0, start_routine, arg)) |
669 | if (pthread_create (&id, &attr, start_routine, arg)) |
660 | cleanup ("unable to create a new thread"); |
670 | cleanup ("unable to create a new thread"); |
661 | |
671 | |
662 | pthread_sigmask (SIG_SETMASK, &oldsigset, 0); |
672 | pthread_sigmask (SIG_SETMASK, &oldsigset, 0); |
663 | } |
673 | } |
|
|
674 | |