*** busybox version 1.15.0 *** No matter what duration I feed to sleep(1), it exits immediately. sleep(3) itself works fine on the target. The problem only occurs when CONFIG_FEATURE_FANCY_SLEEP and CONFIG_FEATURE_FLOAT_SLEEP are enabled. Example output: # sleep BusyBox v1.15.0 (2009-09-08 16:05:44 CST) multi-call binary ... # time sleep 10 real 0m 0.00s user 0m 0.00s sys 0m 0.00s # time sleep 10s real 0m 0.00s user 0m 0.00s sys 0m 0.00s # time sleep 10m real 0m 0.00s user 0m 0.00s sys 0m 0.00s # sleep 10 # echo $? 0
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.