Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 487592 - OpenRC: Add timing info to parallel startup output
Summary: OpenRC: Add timing info to parallel startup output
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: OpenRC (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: OpenRC Team
Depends on:
Reported: 2013-10-11 04:06 UTC by Patrick Lauer
Modified: 2023-01-29 03:10 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Lauer gentoo-dev 2013-10-11 04:06:36 UTC
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;
Comment 1 William Hubbs gentoo-dev 2013-10-11 17:26:35 UTC
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.


Comment 2 Patrick Lauer gentoo-dev 2013-10-12 02:38:46 UTC
For portability one should use clock_gettime instead of diddling around in /proc

manpage says:

       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 ...
Comment 3 William Hubbs gentoo-dev 2013-10-13 20:45:50 UTC
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).
Comment 4 William Hubbs gentoo-dev 2013-10-13 22:58:04 UTC
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.