Send only SIGHUP in sandman
parent
e01b03c963
commit
b1427dd169
4
event.c
4
event.c
|
@ -120,6 +120,7 @@ noreturn void eventLoop(void) {
|
||||||
};
|
};
|
||||||
sigaction(SIGCHLD, &action, NULL);
|
sigaction(SIGCHLD, &action, NULL);
|
||||||
sigaction(SIGINT, &action, NULL);
|
sigaction(SIGINT, &action, NULL);
|
||||||
|
sigaction(SIGHUP, &action, NULL);
|
||||||
|
|
||||||
struct sigaction curses;
|
struct sigaction curses;
|
||||||
sigaction(SIGWINCH, &action, &curses);
|
sigaction(SIGWINCH, &action, &curses);
|
||||||
|
@ -130,6 +131,7 @@ noreturn void eventLoop(void) {
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (sig[SIGCHLD]) childWait();
|
if (sig[SIGCHLD]) childWait();
|
||||||
|
if (sig[SIGHUP]) ircFmt("QUIT :zzz\r\n");
|
||||||
if (sig[SIGINT]) {
|
if (sig[SIGINT]) {
|
||||||
signal(SIGINT, SIG_DFL);
|
signal(SIGINT, SIG_DFL);
|
||||||
ircFmt("QUIT :Goodbye\r\n");
|
ircFmt("QUIT :Goodbye\r\n");
|
||||||
|
@ -139,7 +141,7 @@ noreturn void eventLoop(void) {
|
||||||
uiRead();
|
uiRead();
|
||||||
uiDraw();
|
uiDraw();
|
||||||
}
|
}
|
||||||
sig[SIGCHLD] = sig[SIGINT] = sig[SIGWINCH] = 0;
|
sig[SIGCHLD] = sig[SIGHUP] = sig[SIGINT] = sig[SIGWINCH] = 0;
|
||||||
|
|
||||||
struct pollfd fds[3] = {
|
struct pollfd fds[3] = {
|
||||||
{ .events = POLLIN, .fd = irc },
|
{ .events = POLLIN, .fd = irc },
|
||||||
|
|
12
sandman.1
12
sandman.1
|
@ -16,14 +16,10 @@ is a utility for Darwin systems.
|
||||||
It runs the
|
It runs the
|
||||||
.Ar command
|
.Ar command
|
||||||
as a child process
|
as a child process
|
||||||
and sends it
|
and sends it the
|
||||||
.Dv SIGTSTP
|
.Dv SIGHUP
|
||||||
and
|
signal
|
||||||
.Dv SIGCONT
|
when the system goes to sleep.
|
||||||
signals
|
|
||||||
when the system goes to sleep
|
|
||||||
and wakes from sleep,
|
|
||||||
respectively.
|
|
||||||
.
|
.
|
||||||
.Sh EXIT STATUS
|
.Sh EXIT STATUS
|
||||||
.Nm
|
.Nm
|
||||||
|
|
14
sandman.m
14
sandman.m
|
@ -59,19 +59,7 @@ int main(int argc, char *argv[]) {
|
||||||
queue: nil
|
queue: nil
|
||||||
usingBlock: ^(NSNotification *note) {
|
usingBlock: ^(NSNotification *note) {
|
||||||
(void)note;
|
(void)note;
|
||||||
int error = kill(pid, SIGTSTP);
|
int error = kill(pid, SIGHUP);
|
||||||
if (error) err(EX_UNAVAILABLE, "kill %d", pid);
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
[
|
|
||||||
[[NSWorkspace sharedWorkspace] notificationCenter]
|
|
||||||
addObserverForName: NSWorkspaceDidWakeNotification
|
|
||||||
object: nil
|
|
||||||
queue: nil
|
|
||||||
usingBlock: ^(NSNotification *note) {
|
|
||||||
(void)note;
|
|
||||||
int error = kill(pid, SIGCONT);
|
|
||||||
if (error) err(EX_UNAVAILABLE, "kill %d", pid);
|
if (error) err(EX_UNAVAILABLE, "kill %d", pid);
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue