[Bug 603] sleep(1) exits immediately when FANCY_SLEEP and/or FLOAT_SLEEP are enabled
bugzilla at busybox.net
bugzilla at busybox.net
Wed Sep 9 20:48:01 UTC 2009
https://bugs.busybox.net/show_bug.cgi?id=603
--- Comment #1 from Denys Vlasenko <vda.linux at googlemail.com> 2009-09-09 20:48:00 UTC ---
Please add the lines with bb_error_msg (shown as non-indented lines)
in sleep.c in the fragment below:
#if ENABLE_FEATURE_FLOAT_SLEEP
duration = 0;
do {
char *arg = *argv;
if (strchr(arg, '.')) {
double d;
char *pp;
int len = strspn(arg, "0123456789.");
char sv = arg[len];
arg[len] = '\0';
errno = 0;
d = strtod(arg, &pp);
if (errno || *pp)
bb_show_usage();
arg[len] = sv;
len--;
sv = arg[len];
arg[len] = '1';
duration += d * xatoul_sfx(&arg[len], sfx);
arg[len] = sv;
} else
duration += xatoul_sfx(arg, sfx);
bb_error_msg("arg:%s dur:%f", arg, duration);
} while (*++argv);
ts.tv_sec = MAXINT(typeof(ts.tv_sec));
ts.tv_nsec = 0;
if (duration >= 0 && duration < ts.tv_sec) {
ts.tv_sec = duration;
ts.tv_nsec = (duration - ts.tv_sec) * 1000000000;
}
bb_error_msg("sec:%u nsec:%u", (unsigned)ts.tv_sec, (unsigned)ts.tv_nsec);
do {
errno = 0;
nanosleep(&ts, &ts);
} while (errno == EINTR);
recompile, and run "sleep 1". What does it say?
I tested it, and for me it says:
# ./busybox sleep 1
sleep: arg:1 dur:1.000000
sleep: sec:1 nsec:0
[sleeps 1 sec]
# ./busybox sleep 1 2m 3.45
sleep: arg:1 dur:1.000000
sleep: arg:2m dur:121.000000
sleep: arg:3.45 dur:124.450000
sleep: sec:124 nsec:450000000
[sleeps]
--
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the busybox-cvs
mailing list