aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2016-01-16 20:05:58 -0500
committerFranklin Wei <git@fwei.tk>2016-01-16 20:05:58 -0500
commit98896de83ffa7380404e41b6ed80cfc6ba3bf8f0 (patch)
tree427f48b92d647c6278df083f86d33a7545710a6c /src/util.c
parent056220075ca575c17899abea7b3a2fb55e64b561 (diff)
downloadnetcosm-98896de83ffa7380404e41b6ed80cfc6ba3bf8f0.zip
netcosm-98896de83ffa7380404e41b6ed80cfc6ba3bf8f0.tar.gz
netcosm-98896de83ffa7380404e41b6ed80cfc6ba3bf8f0.tar.bz2
netcosm-98896de83ffa7380404e41b6ed80cfc6ba3bf8f0.tar.xz
packetized requests
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/util.c b/src/util.c
index 2c10eef..6d2d184 100644
--- a/src/util.c
+++ b/src/util.c
@@ -25,7 +25,7 @@ void remove_cruft(char *str)
}
/**
- * WARNING: not signal-safe
+ * WARNING: not signal-safe AT ALL
* TODO: rewrite to avoid calling *printf()
*/
void debugf_real(const char *func, int line, const char *file, const char *fmt, ...)
@@ -33,6 +33,11 @@ void debugf_real(const char *func, int line, const char *file, const char *fmt,
(void) func;
(void) line;
(void) file;
+ static int fd = -1;
+ if(fd < 0)
+ fd = open(LOGFILE, O_APPEND | O_WRONLY | O_CREAT, 0600);
+ if(fd < 0)
+ error("unknown");
int len;
#if 0
char *prefix;
@@ -48,6 +53,8 @@ void debugf_real(const char *func, int line, const char *file, const char *fmt,
len = vasprintf(&buf, fmt, ap);
write(STDOUT_FILENO, buf, len);
+ write(fd, buf, len);
+ fflush(fdopen(fd, "a"));
free(buf);