Support #562
macos slow xadmin stop
Status: | Closed | Start date: | 06/27/2020 | |
---|---|---|---|---|
Priority: | Normal (Code 4) | Due date: | ||
Assignee: | - | % Done: | 100% | |
Category: | - | |||
Target version: | - |
History
#1 Updated by Madars about 3 years ago
- Tracker changed from Bug to Support
#2 Updated by Madars about 3 years ago
sigwait() is broken for macos, thus we are using sleep(1) in signal thread.
The best we could do is:
- reduce the logs
- make sleep as 500ms or less.. Then we could get better response
#3 Updated by Madars about 3 years ago
#4 Updated by Madars about 3 years ago
The other option would be to:
- use waitpid() to block if have childs
- if no childs exists, then loop with say 1 sec interval
- use disable/enable cancelation around waitpid();
-The termination thread would send cancel to signal thread.
Thus process shutdown shall be fast. Also around the sleep cancelation should be enabled too have a fast shutdowns.
bash-3.2$ cat cancel.c #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <pthread.h> #include <sys/wait.h> #include <stdlib.h> int count = 0; pthread_t sample_thread; void* thread_two_func(void* p) { pid_t cpid, w; int status; struct rusage usage; int old; pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old); pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &old); sample_thread = pthread_self(); //store the id of thread 2 while (1) { printf("This is thread 2\n"); pid_t pid2 = waitpid(-1, &status, 0); if (pid2 == -1) { perror("waitpid"); exit(-1); } printf("INTTR\n"); } } int main(int argc, char **argv) { sigset_t x; sigemptyset (&x); sigaddset(&x, SIGCHLD); sigaddset(&x, SIGINT); sigprocmask(SIG_BLOCK, &x, NULL); pthread_t t1, t2; int old; if (0==fork()) { sleep(5); } //create two threads pthread_create(&t2, NULL, thread_two_func, NULL); sleep(1); printf("send cancel\n"); pthread_cancel(t2); //wait for completing threads pthread_join(t2, NULL); }
Note that wait3() does not respond to cancel.
#5 Updated by Madars about 3 years ago
- Status changed from New to Resolved
- % Done changed from 0 to 100
fixed in 7.5.0+
#6 Updated by Madars about 3 years ago
- Status changed from Resolved to Closed