diff options
author | cheloha <cheloha@cvs.openbsd.org> | 2018-02-09 23:12:14 +0000 |
---|---|---|
committer | cheloha <cheloha@cvs.openbsd.org> | 2018-02-09 23:12:14 +0000 |
commit | d6478edad60bb262d6f85b906dfcea71dbcbf473 (patch) | |
tree | 1487132bf46b9c68f25411ea878e0f32f17b7c9c /usr.bin/leave | |
parent | 1d6f4c6b34f3aeeb9177c36aac417d27a652445e (diff) |
Schedule alarm for start of minute if departure time is absolute.
e.g., "leave 1530" goes off closer to 15:30:00.
Timezone-related bug caught by tb@ in review.
ok tb@ tedu@
Diffstat (limited to 'usr.bin/leave')
-rw-r--r-- | usr.bin/leave/leave.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.bin/leave/leave.c b/usr.bin/leave/leave.c index ec11d62735a..78abf8eba8b 100644 --- a/usr.bin/leave/leave.c +++ b/usr.bin/leave/leave.c @@ -1,4 +1,4 @@ -/* $OpenBSD: leave.c,v 1.17 2015/10/09 01:37:08 deraadt Exp $ */ +/* $OpenBSD: leave.c,v 1.18 2018/02/09 23:12:13 cheloha Exp $ */ /* $NetBSD: leave.c,v 1.4 1995/07/03 16:50:13 phil Exp $ */ /* @@ -113,6 +113,7 @@ main(int argc, char *argv[]) secs = (hours - t->tm_hour) * HOUR; secs += (minutes - t->tm_min) * MINUTE; + secs -= t->tm_sec; /* aim for beginning of minute */ } doalarm(secs); exit(0); @@ -155,12 +156,16 @@ doalarm(u_int secs) sleep(secs - MINUTE); if (puts("\a\aJust one more minute!") == EOF) exit(0); + secs = MINUTE; } + sleep(secs); + for (bother = 10; bother--;) { - sleep(MINUTE); if (puts("\a\aTime to leave!") == EOF) exit(0); + if (bother) + sleep(MINUTE); } puts("\a\aThat was the last time I'll tell you. Bye."); |