]> git.sur5r.net Git - i3/i3status/blobdiff - src/general.c
Use kill(pid, 0) to check if the process is alive
[i3/i3status] / src / general.c
index 4016ecdbf0902bf26c9859b7cd3e2643e08428ff..2ae90f135ed2dad3f6ff788e2905af0b345aa3f1 100644 (file)
@@ -1,3 +1,4 @@
+// vim:ts=8:expandtab
 #include <sys/types.h>
 #include <string.h>
 #include <stdarg.h>
  * Reads size bytes into the destination buffer from filename.
  *
  */
-void slurp(char *filename, char *destination, int size) {
-       int fd;
+bool slurp(const char *filename, char *destination, int size) {
+        int fd;
 
-       if ((fd = open(filename, O_RDONLY)) == -1)
-               die("Could not open \"%s\"\n", filename);
+        if ((fd = open(filename, O_RDONLY)) == -1)
+                return false;
 
-       (void)read(fd, destination, size);
-       (void)close(fd);
+        (void)read(fd, destination, size);
+        (void)close(fd);
+
+        return true;
 }
 
 /*
@@ -50,21 +53,6 @@ void die(const char *fmt, ...) {
         (void)vsnprintf(buffer, sizeof(buffer), fmt, ap);
         va_end(ap);
 
-        if (wmii_path != NULL)
-                write_error_to_statusbar(buffer);
-        else
-                fprintf(stderr, "%s", buffer);
+        fprintf(stderr, "%s", buffer);
         exit(EXIT_FAILURE);
 }
-
-/*
- * This function just concats two strings in place, it should only be used
- * for concatting order to the name of a file or concatting color codes.
- * Otherwise, the buffer size would have to be increased.
- *
- */
-char *concat(const char *str1, const char *str2) {
-        static char concatbuf[32];
-        (void)snprintf(concatbuf, sizeof(concatbuf), "%s%s", str1, str2);
-        return concatbuf;
-}