-/* $OpenBSD: init.c,v 1.66 2018/01/06 16:26:12 millert Exp $ */
+/* $OpenBSD: init.c,v 1.67 2018/01/31 15:57:44 cheloha Exp $ */
/* $NetBSD: init.c,v 1.22 1996/05/15 23:29:33 jtc Exp $ */
/*-
typedef struct init_session {
int se_index; /* index of entry in ttys file */
pid_t se_process; /* controlling process */
- time_t se_started; /* used to avoid thrashing */
+ struct timespec se_started; /* used to avoid thrashing */
int se_flags; /* status of session */
#define SE_SHUTDOWN 0x1 /* session won't be restarted */
#define SE_PRESENT 0x2 /* session is in /etc/ttys */
{
pid_t pid;
sigset_t mask;
- time_t current_time = time(NULL);
+ struct timespec current_time, elapsed;
int p[2], new = 1;
if (sp->se_flags & SE_DEVEXISTS)
sleep(1);
}
- if (current_time > sp->se_started &&
- current_time - sp->se_started < GETTY_SPACING) {
- warning("getty repeating too quickly on port %s, sleeping",
- sp->se_device);
- sleep(GETTY_SLEEP);
+ if (timespecisset(&sp->se_started)) {
+ clock_gettime(CLOCK_MONOTONIC, ¤t_time);
+ timespecsub(¤t_time, &sp->se_started, &elapsed);
+ if (elapsed.tv_sec < GETTY_SPACING) {
+ warning(
+ "getty repeating too quickly on port %s, sleeping",
+ sp->se_device);
+ sleep(GETTY_SLEEP);
+ }
}
if (sp->se_window) {
}
sp->se_process = pid;
- sp->se_started = time(NULL);
+ clock_gettime(CLOCK_MONOTONIC, &sp->se_started);
add_session(sp);
}
break;
}
sp->se_process = pid;
- sp->se_started = time(NULL);
+ clock_gettime(CLOCK_MONOTONIC, &sp->se_started);
add_session(sp);
}