Only applied to the parallel startup case because it pretty-prints nicer. Enhanced output for parallel startup, prints timing info using time since boot from /proc/uptime. Example: udev 0.34| * Starting udev ... udev 0.35| [ ok ] First attempt, might be horribly bad code, but it gets the job done. diff --git a/src/rc/runscript.c b/src/rc/runscript.c index 0eea335..716db34 100644 --- a/src/rc/runscript.c +++ b/src/rc/runscript.c @@ -335,9 +337,18 @@ write_prefix(const char *buffer, size_t bytes, bool *prefixed) } if (!*prefixed) { + /* read timestamp from /proc/uptime */ + int uptime_fd; + char *u_buf[1024]; + char *uptime; + uptime_fd=open("/proc/uptime", 0); + read(uptime_fd, u_buf, 1024); + uptime=strtok(&u_buf, " "); + ret += write(fd, ec, strlen(ec)); ret += write(fd, prefix, strlen(prefix)); ret += write(fd, ec_normal, strlen(ec_normal)); + ret += write(fd, uptime, strlen(uptime)); ret += write(fd, "|", 1); *prefixed = true; }
Does this work on *bsd as well? Also, in the future, can you please attach patches instead of posting them inline in the comments? patches in the comments cannot be applied directly, so they are not really useful. Thanks, William
For portability one should use clock_gettime instead of diddling around in /proc manpage says: CONFORMING TO SUSv2, POSIX.1-2001 has a different API, but allows better resolution if the system provides it. I might just try to cook up a patch ...
I was asking about *BSD to decide whether to put this in anto determine whether I need to use #ifdef __LINUX__ ... #endif or not. I am concerned about switching to clock_gettime, because it would also have the same questions, and it appears to require some complexity in linking (see the man page for clock_gettime).
The complexity in linking is that if we are using glibc and <glibc-2.17, we have to also link with -lrt, but, if glibc is at least 2.17, we don't need to do that. If we switch to clock_gettime, I think it would be best to hold off on implementing this until at least glibc-2.17 is stable.