/*
* i3bar - an xcb-based status- and ws-bar for i3
*
- * © 2010 Axel Wagner and contributors
+ * © 2010-2011 Axel Wagner and contributors
*
* See file LICNSE for license information
*
void cleanup() {
if (stdin_io != NULL) {
ev_io_stop(main_loop, stdin_io);
- ev_child_stop(main_loop, child_sig);
FREE(stdin_io);
- FREE(child_sig);
FREE(statusline_buffer);
+ /* statusline pointed to memory within statusline_buffer */
+ statusline = NULL;
+ }
+
+ if (child_sig != NULL) {
+ ev_child_stop(main_loop, child_sig);
+ FREE(child_sig);
}
}
exit(EXIT_FAILURE);
}
if (n == 0) {
- if (rec == buffer_len) {
- buffer_len += STDIN_CHUNK_SIZE;
- buffer = realloc(buffer, buffer_len);
- } else {
- if (rec != 0) {
- /* remove trailing newline and finish up */
- buffer[rec-1] = '\0';
- }
- break;
+ if (rec != 0) {
+ /* remove trailing newline and finish up */
+ buffer[rec-1] = '\0';
}
+
+ /* end of file, kill the watcher */
+ ELOG("stdin: received EOF\n");
+ cleanup();
+ draw_bars();
+ return;
}
rec += n;
+
+ if (rec == buffer_len) {
+ buffer_len += STDIN_CHUNK_SIZE;
+ buffer = realloc(buffer, buffer_len);
+ }
}
if (*buffer == '\0') {
FREE(buffer);
*
*/
void child_sig_cb(struct ev_loop *loop, ev_child *watcher, int revents) {
- DLOG("Child (pid: %d) unexpectedly exited with status %d\n",
+ ELOG("Child (pid: %d) unexpectedly exited with status %d\n",
child_pid,
watcher->rstatus);
cleanup();