AuthorizationExecuteWithPrivileges leaves behind a zombie process that persists until the application either exits or calls waitpid on it. If you go long enough without either quitting the app or restarting the computer, this eventually starts causing problems as the root user accumulates hundreds of defunct processes (two new processes every time the computer wakes from sleep and turbo boost is re-disabled). Unfortunately, the function doesn't provide the child process's pid, which makes reaping the child process a little complicated. A quick search shows people have found two solutions to the problem:
Have the child process echo its pid and retrieve it from the communications pipe to pass to waitpid
Call while (waitpid(-1, 0, WNOHANG) > 0); afterward to attempt to reap all stopped child processes. Simply calling wait(NULL); immediately afterward should also work if you're not worried about the child process never exiting for some reason.
I tested the second solution and found that it leaves the latest child process lying around, but that's harmless compared to what's happening now.
AuthorizationExecuteWithPrivileges leaves behind a zombie process that persists until the application either exits or calls waitpid on it. If you go long enough without either quitting the app or restarting the computer, this eventually starts causing problems as the root user accumulates hundreds of defunct processes (two new processes every time the computer wakes from sleep and turbo boost is re-disabled). Unfortunately, the function doesn't provide the child process's pid, which makes reaping the child process a little complicated. A quick search shows people have found two solutions to the problem:
waitpid
while (waitpid(-1, 0, WNOHANG) > 0);
afterward to attempt to reap all stopped child processes. Simply callingwait(NULL);
immediately afterward should also work if you're not worried about the child process never exiting for some reason.I tested the second solution and found that it leaves the latest child process lying around, but that's harmless compared to what's happening now.