← Commit list

ec16c030b

Denys Vlasenko
Denys Vlasenko
2020-11-29
SUCCESS Duration: 153s

Subject

libbb: introduce and use sleep1()

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

coreutils/timeout.c+1 -1
@@ -105,7 +105,7 @@ int timeout_main(int argc UNUSED_PARAM, char **argv)
grandchild:
/* Just sleep(HUGE_NUM); kill(parent) may kill wrong process! */
while (1) {
- sleep(1);
+ sleep1();
if (--timeout <= 0)
break;
if (kill(parent, 0)) {
e2fsprogs/fsck.c+1 -1
@@ -480,7 +480,7 @@ static int wait_one(int flags)
* time to set up the signal handler
*/
if (inst2->start_time >= time(NULL) - 1)
- sleep(1);
+ sleep1();
kill(inst2->pid, SIGUSR1);
inst2->flags |= FLAG_PROGRESS;
break;
include/libbb.h+1 -3
@@ -1601,11 +1601,9 @@ char *bb_simplify_path(const char *path) FAST_FUNC;
/* Returns ptr to NUL */
char *bb_simplify_abs_path_inplace(char *path) FAST_FUNC;
-#ifndef LOGIN_FAIL_DELAY
-#define LOGIN_FAIL_DELAY 3
-#endif
void pause_after_failed_login(void) FAST_FUNC;
void bb_do_delay(int seconds) FAST_FUNC;
+void sleep1(void) FAST_FUNC;
void change_identity(const struct passwd *pw) FAST_FUNC;
void run_shell(const char *shell, int loginshell, const char **args) NORETURN FAST_FUNC;
init/halt.c+2 -2
@@ -144,14 +144,14 @@ static int init_was_not_there(void)
*/
#if 0
while (kill(1, 0) != 0 && --cnt >= 0)
- sleep(1);
+ sleep1();
#endif
/* ... so let's wait for some evidence a usual startup event,
* mounting of /proc, happened. By that time init should be ready
* for signals.
*/
while (access("/proc/meminfo", F_OK) != 0 && --cnt >= 0)
- sleep(1);
+ sleep1();
/* Does it look like init wasn't there? */
return (cnt != initial - 1);
init/init.c+6 -6
@@ -736,7 +736,7 @@ static void pause_and_low_level_reboot(unsigned magic)
pid_t pid;
/* Allow time for last message to reach serial console, etc */
- sleep(1);
+ sleep1();
/* We have to fork here, since the kernel calls do_exit(EXIT_SUCCESS)
* in linux/kernel/sys.c, which can cause the machine to panic when
@@ -751,7 +751,7 @@ static void pause_and_low_level_reboot(unsigned magic)
* we would eternally sleep here - not what we want.
*/
waitpid(pid, NULL, 0);
- sleep(1); /* paranoia */
+ sleep1(); /* paranoia */
_exit(EXIT_SUCCESS);
}
@@ -768,12 +768,12 @@ static void run_shutdown_and_kill_processes(void)
kill(-1, SIGTERM);
message(L_CONSOLE, "Sent SIG%s to all processes", "TERM");
sync();
- sleep(1);
+ sleep1();
kill(-1, SIGKILL);
message(L_CONSOLE, "Sent SIG%s to all processes", "KILL");
sync();
- /*sleep(1); - callers take care about making a pause */
+ /*sleep1(); - callers take care about making a pause */
}
/* Signal handling by init:
@@ -904,7 +904,7 @@ static void stop_handler(int sig UNUSED_PARAM)
wpid = wait_any_nohang(NULL);
mark_terminated(wpid);
if (wpid <= 0) /* no processes exited? sleep a bit */
- sleep(1);
+ sleep1();
}
signal(SIGCONT, SIG_DFL);
@@ -1209,7 +1209,7 @@ int init_main(int argc UNUSED_PARAM, char **argv)
}
/* Don't consume all CPU time - sleep a bit */
- sleep(1);
+ sleep1();
} /* while (1) */
}
libbb/bb_do_delay.c+6 -0
@@ -28,3 +28,9 @@ void FAST_FUNC pause_after_failed_login(void)
sleep(LOGIN_FAIL_DELAY);
#endif
}
+
+void FAST_FUNC sleep1(void)
+{
+ sleep(1);
+}
+
loginutils/getty.c+1 -1
@@ -434,7 +434,7 @@ static void auto_baud(void)
* Wait for a while, then read everything the modem has said so far and
* try to extract the speed of the dial-in call.
*/
- sleep(1);
+ sleep1();
nread = safe_read(STDIN_FILENO, G.line_buf, sizeof(G.line_buf) - 1);
if (nread > 0) {
int speed;
miscutils/chat.c+1 -1
@@ -473,7 +473,7 @@ int chat_main(int argc UNUSED_PARAM, char **argv)
if ('\\' == c) {
c = *++buf;
if ('d' == c) {
- sleep(1);
+ sleep1();
len--;
continue;
}
miscutils/hdparm.c+2 -2
@@ -1436,7 +1436,7 @@ static void flush_buffer_cache(/*int fd*/ void)
fsync(fd); /* flush buffers */
ioctl_or_warn(fd, BLKFLSBUF, NULL); /* do it again, big time */
#ifdef HDIO_DRIVE_CMD
- sleep(1);
+ sleep1();
if (ioctl(fd, HDIO_DRIVE_CMD, NULL) && errno != EINVAL) { /* await completion */
if (ENABLE_IOCTL_HEX2STR_ERROR) /* To be coherent with ioctl_or_warn */
bb_simple_perror_msg("HDIO_DRIVE_CMD");
@@ -1511,7 +1511,7 @@ static void do_time(int cache /*,int fd*/)
* NB: *small* delay. User is expected to have a clue and to not run
* heavy io in parallel with measurements. */
sync();
- sleep(1);
+ sleep1();
if (cache) { /* Time cache */
seek_to_zero();
read_big_block(buf);
networking/ifplugd.c+1 -1
@@ -735,7 +735,7 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv)
delay_time += G.delay_down;
#if 0 /* if you are back in 1970... */
if (delay_time == 0) {
- sleep(1);
+ sleep1();
delay_time = 1;
}
#endif
networking/inetd.c+2 -2
@@ -1305,7 +1305,7 @@ int inetd_main(int argc UNUSED_PARAM, char **argv)
if (ready_fd_cnt < 0) {
if (errno != EINTR) {
bb_simple_perror_msg("select");
- sleep(1);
+ sleep1();
}
continue;
}
@@ -1406,7 +1406,7 @@ int inetd_main(int argc UNUSED_PARAM, char **argv)
if (pid < 0) { /* fork error */
bb_simple_perror_msg("vfork"+1);
- sleep(1);
+ sleep1();
restore_sigmask(&omask);
maybe_close(new_udp_fd);
maybe_close(accepted_fd);
networking/nbd-client.c+1 -1
@@ -270,7 +270,7 @@ int nbdclient_main(int argc, char **argv)
close(fd);
break;
}
- sleep(1);
+ sleep1();
}
open(device, O_RDONLY);
return 0;
networking/nc_bloaty.c+1 -1
@@ -196,7 +196,7 @@ enum {
/* Debug: squirt whatever message and sleep a bit so we can see it go by. */
/* Beware: writes to stdOUT... */
#if 0
-#define Debug(...) do { printf(__VA_ARGS__); printf("\n"); fflush_all(); sleep(1); } while (0)
+#define Debug(...) do { printf(__VA_ARGS__); printf("\n"); fflush_all(); sleep1(); } while (0)
#else
#define Debug(...) do { } while (0)
#endif
networking/slattach.c+1 -1
@@ -76,7 +76,7 @@ static void restore_state_and_exit(int exitcode)
cfsetispeed(&state, B0);
cfsetospeed(&state, B0);
exitcode |= tcsetattr_serial_or_warn(&state);
- sleep(1);
+ sleep1();
/* Restore line status */
if (tcsetattr_serial_or_warn(&G.saved_state))
networking/telnet.c+1 -1
@@ -673,7 +673,7 @@ int telnet_main(int argc UNUSED_PARAM, char **argv)
if (bb_got_signal)
con_escape();
else
- sleep(1);
+ sleep1();
continue;
}
runit/runsv.c+2 -2
@@ -651,7 +651,7 @@ int runsv_main(int argc UNUSED_PARAM, char **argv)
gettimeofday_ns(&svd[0].start);
update_status(&svd[0]);
if (LESS(svd[0].start.tv_sec, deadline))
- sleep(1);
+ sleep1();
}
if (haslog) {
if (child == svd[1].pid) {
@@ -664,7 +664,7 @@ int runsv_main(int argc UNUSED_PARAM, char **argv)
gettimeofday_ns(&svd[1].start);
update_status(&svd[1]);
if (LESS(svd[1].start.tv_sec, deadline))
- sleep(1);
+ sleep1();
}
}
} /* for (;;) */
sysklogd/logread.c+1 -1
@@ -180,7 +180,7 @@ int logread_main(int argc UNUSED_PARAM, char **argv)
if (cur == shbuf_tail) {
sem_up(log_semid);
fflush_all();
- sleep(1); /* TODO: replace me with a sleep_on */
+ sleep1(); /* TODO: replace me with a sleep_on */
continue;
}
}
util-linux/fdisk.c+1 -1
@@ -2667,7 +2667,7 @@ reread_partition_table(int leave)
/* Users with slow external USB disks on a 320MHz ARM system (year 2011)
* report that sleep is needed, otherwise BLKRRPART may fail with -EIO:
*/
- sleep(1);
+ sleep1();
i = ioctl_or_perror(dev_fd, BLKRRPART, NULL,
"WARNING: rereading partition table "
"failed, kernel still uses old table");
util-linux/mdev.c+1 -1
@@ -920,7 +920,7 @@ static void load_firmware(const char *firmware, const char *sysfs_path)
loading_fd = open("loading", O_WRONLY);
if (loading_fd >= 0)
goto loading;
- sleep(1);
+ sleep1();
}
goto out;