dwm is now exit, if stdin is closed due broken pipe
0cf3ba0e
1 file(s) · +5 −8
| 165 | 165 | int i; |
|
| 166 | 166 | unsigned int mask; |
|
| 167 | 167 | fd_set rd; |
|
| 168 | - | Bool readin = True; |
|
| 169 | 168 | Window w; |
|
| 170 | 169 | XEvent ev; |
|
| 171 | 170 | XSetWindowAttributes wa; |
|
| 252 | 251 | /* main event loop, reads status text from stdin as well */ |
|
| 253 | 252 | while(running) { |
|
| 254 | 253 | FD_ZERO(&rd); |
|
| 255 | - | if(readin) |
|
| 256 | - | FD_SET(STDIN_FILENO, &rd); |
|
| 254 | + | FD_SET(STDIN_FILENO, &rd); |
|
| 257 | 255 | FD_SET(ConnectionNumber(dpy), &rd); |
|
| 258 | 256 | ||
| 259 | 257 | i = select(ConnectionNumber(dpy) + 1, &rd, 0, 0, 0); |
|
| 269 | 267 | (handler[ev.type])(&ev); /* call handler */ |
|
| 270 | 268 | } |
|
| 271 | 269 | } |
|
| 272 | - | if(readin && FD_ISSET(STDIN_FILENO, &rd)) { |
|
| 273 | - | readin = NULL != fgets(stext, sizeof(stext), stdin); |
|
| 274 | - | if(readin) |
|
| 270 | + | if(FD_ISSET(STDIN_FILENO, &rd)) { |
|
| 271 | + | if(!fgets(stext, sizeof(stext), stdin)) |
|
| 272 | + | break; |
|
| 273 | + | else |
|
| 275 | 274 | stext[strlen(stext) - 1] = 0; |
|
| 276 | - | else |
|
| 277 | - | strcpy(stext, "broken pipe"); |
|
| 278 | 275 | drawstatus(); |
|
| 279 | 276 | } |
|
| 280 | 277 | } |
|