ruderich.org/simon
/
wall-notify
/
wall-notify.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
5f81deb
)
fix race condition in handle_wall()
author
Simon Ruderich
<simon@ruderich.org>
Thu, 23 Oct 2014 09:32:48 +0000
(11:32 +0200)
committer
Simon Ruderich
<simon@ruderich.org>
Thu, 23 Oct 2014 09:32:48 +0000
(11:32 +0200)
If a signal occurred before the while loop is reached, it was lost.
src/wall-notify.c
patch
|
blob
|
history
diff --git
a/src/wall-notify.c
b/src/wall-notify.c
index 95c4d8f8fad53d19534e449aff21b5c078914f30..efe500513f760cff017b631486c6cabfbf6094c2 100644
(file)
--- a/
src/wall-notify.c
+++ b/
src/wall-notify.c
@@
-48,8
+48,13
@@
#endif
+static sig_atomic_t signaled = 0;
+
+
static void sig_handler(int signal) {
(void)signal;
+
+ signaled = 1;
}
static void setup_signals(void) {
struct sigaction action;
@@
-332,7
+337,7
@@
static void handle_wall(int fd, char **argv) {
ssize_t r;
assert(SSIZE_MAX <= SIZE_MAX);
- while ((r = read(fd, buffer, sizeof(buffer))) > 0) {
+ while (
!signaled &&
(r = read(fd, buffer, sizeof(buffer))) > 0) {
size_t space;
ssize_t r2;