Browse Source

Send only SIGHUP in sandman

June 1 week ago
parent
commit
b1427dd169
Signed by: Curtis McEnroe <june@causal.agency> GPG Key ID: CEA2F97ADCFCD77C
3 changed files with 8 additions and 22 deletions
  1. 3
    1
      event.c
  2. 4
    8
      sandman.1
  3. 1
    13
      sandman.m

+ 3
- 1
event.c View File

@@ -120,6 +120,7 @@ noreturn void eventLoop(void) {
120 120
 	};
121 121
 	sigaction(SIGCHLD, &action, NULL);
122 122
 	sigaction(SIGINT, &action, NULL);
123
+	sigaction(SIGHUP, &action, NULL);
123 124
 
124 125
 	struct sigaction curses;
125 126
 	sigaction(SIGWINCH, &action, &curses);
@@ -130,6 +131,7 @@ noreturn void eventLoop(void) {
130 131
 
131 132
 	for (;;) {
132 133
 		if (sig[SIGCHLD]) childWait();
134
+		if (sig[SIGHUP]) ircFmt("QUIT :zzz\r\n");
133 135
 		if (sig[SIGINT]) {
134 136
 			signal(SIGINT, SIG_DFL);
135 137
 			ircFmt("QUIT :Goodbye\r\n");
@@ -139,7 +141,7 @@ noreturn void eventLoop(void) {
139 141
 			uiRead();
140 142
 			uiDraw();
141 143
 		}
142
-		sig[SIGCHLD] = sig[SIGINT] = sig[SIGWINCH] = 0;
144
+		sig[SIGCHLD] = sig[SIGHUP] = sig[SIGINT] = sig[SIGWINCH] = 0;
143 145
 
144 146
 		struct pollfd fds[3] = {
145 147
 			{ .events = POLLIN, .fd = irc },

+ 4
- 8
sandman.1 View File

@@ -16,14 +16,10 @@ is a utility for Darwin systems.
16 16
 It runs the
17 17
 .Ar command
18 18
 as a child process
19
-and sends it
20
-.Dv SIGTSTP
21
-and
22
-.Dv SIGCONT
23
-signals
24
-when the system goes to sleep
25
-and wakes from sleep,
26
-respectively.
19
+and sends it the
20
+.Dv SIGHUP
21
+signal
22
+when the system goes to sleep.
27 23
 .
28 24
 .Sh EXIT STATUS
29 25
 .Nm

+ 1
- 13
sandman.m View File

@@ -59,19 +59,7 @@ int main(int argc, char *argv[]) {
59 59
 		queue: nil
60 60
 		usingBlock: ^(NSNotification *note) {
61 61
 			(void)note;
62
-			int error = kill(pid, SIGTSTP);
63
-			if (error) err(EX_UNAVAILABLE, "kill %d", pid);
64
-		}
65
-	];
66
-	
67
-	[
68
-		[[NSWorkspace sharedWorkspace] notificationCenter]
69
-		addObserverForName: NSWorkspaceDidWakeNotification
70
-		object: nil
71
-		queue: nil
72
-		usingBlock: ^(NSNotification *note) {
73
-			(void)note;
74
-			int error = kill(pid, SIGCONT);
62
+			int error = kill(pid, SIGHUP);
75 63
 			if (error) err(EX_UNAVAILABLE, "kill %d", pid);
76 64
 		}
77 65
 	];

Loading…
Cancel
Save