SCDNotifierInformViaSignal.c [plain text]
#include <mach/mach.h>
#include <mach/mach_error.h>
#include <SystemConfiguration/SystemConfiguration.h>
#include <SystemConfiguration/SCPrivate.h>
#include "SCDynamicStoreInternal.h"
#include "config.h"
Boolean
SCDynamicStoreNotifySignal(SCDynamicStoreRef store, pid_t pid, int sig)
{
SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store;
kern_return_t status;
int sc_status;
task_t task;
if (store == NULL) {
_SCErrorSet(kSCStatusNoStoreSession);
return FALSE;
}
if (storePrivate->server == MACH_PORT_NULL) {
_SCErrorSet(kSCStatusNoStoreServer);
return FALSE;
}
if (storePrivate->notifyStatus != NotifierNotRegistered) {
_SCErrorSet(kSCStatusNotifierActive);
return FALSE;
}
status = task_for_pid(mach_task_self(), pid, &task);
if (status != KERN_SUCCESS) {
SCLog(TRUE, LOG_DEBUG, CFSTR("SCDynamicStoreNotifySignal task_for_pid(): %s"), mach_error_string(status));
_SCErrorSet(status);
return FALSE;
}
retry :
status = notifyviasignal(storePrivate->server, task, sig, (int *)&sc_status);
if (__SCDynamicStoreCheckRetryAndHandleError(store,
status,
&sc_status,
"SCDynamicStoreNotifySignal notifyviasignal()")) {
goto retry;
}
if (status != KERN_SUCCESS) {
_SCErrorSet(status);
return FALSE;
}
storePrivate->notifyStatus = Using_NotifierInformViaSignal;
return TRUE;
}