Support #562

macos slow xadmin stop

Added by Madars almost 4 years ago. Updated almost 4 years ago.

Status:ClosedStart date:06/27/2020
Priority:Normal (Code 4)Due date:
Assignee:-% Done:


Target version:-


#1 Updated by Madars almost 4 years ago

  • Tracker changed from Bug to Support

#2 Updated by Madars almost 4 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

#4 Updated by Madars almost 4 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); }
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())
   //create two threads
   pthread_create(&t2, NULL, thread_two_func, NULL);
printf("send cancel\n");
   //wait for completing threads
   pthread_join(t2, NULL);

Note that wait3() does not respond to cancel.

#5 Updated by Madars almost 4 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

fixed in 7.5.0+

#6 Updated by Madars almost 4 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF