| Summary: | sleep(1) exits immediately when FANCY_SLEEP and/or FLOAT_SLEEP are enabled | ||
|---|---|---|---|
| Product: | Busybox | Reporter: | Ryan <sub> |
| Component: | Other | Assignee: | unassigned |
| Status: | RESOLVED WORKSFORME | ||
| Severity: | normal | CC: | busybox-cvs |
| Priority: | P3 | ||
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | Other | ||
| OS: | Linux | ||
| Host: | Target: | ||
| Build: | |||
|
Description
Ryan
2009-09-09 16:14:25 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]
Hi Denys, # sleep 1 sleep: arg:1 dur:0.000000 sleep: sec:0 nsec:0 # sleep 2m 30 0.5 7h sleep: arg:2m dur:0.000000 sleep: arg:30 dur:0.000000 sleep: arg:0.5 dur:0.000000 sleep: arg:7h dur:0.000000 sleep: sec:0 nsec:0 # But, aha! This bit of debug helped me find the problem on my end. The FPU had been removed. Funny that sleep(1) was the only place we noticed it. I imagine you can now mark this Resolved/WORKSFORME. Thanks for the help. |