# 2.11BSD#431 - /usr/src/lib/libc/gen/sleep.c

##### Functions

    sleep             X

       1: /*
       2:  * Program: sleep.c
       3:  * Copyright: 1997, sms
       4:  * Author: Steven M. Schultz
       5:  *
       6:  * Version   Date	Modification
       7:  *     1.0  1997/9/25	1. Initial release.
       8: */
       9:
      10: #include <stdio.h>  /* For NULL */
      11: #include <sys/types.h>
      12: #include <sys/time.h>
      13:
      14: /*
      15:  * This implements the sleep(3) function using only 3 system calls instead of
      16:  * the 9 that the old implementation required.  Also this version avoids using
      17:  * signals (with the attendant system overhead) and returns the amount of
      18:  * time left unslept if an interrupt occurs.
      19:  *
      20:  * The error status of gettimeofday is not checked because if that fails the
      21:  * program has scrambled the stack so badly that a sleep() failure is the least
      22:  * problem the program has.  The select() call either completes successfully
      23:  * or is interrupted - no errors to be checked for.
      24: */
      25:
      26: u_int
      27: sleep(seconds)
      28:     u_int seconds;
      29:     {
      30:     struct timeval f, s;
      31:
      32:     if  (seconds)
      33:         {
      34:         gettimeofday(&f, NULL);
      35:         s.tv_sec = seconds;
      36:         s.tv_usec = 0;
      37:         select(0, NULL, NULL, NULL, &s);
      38:         gettimeofday(&s, NULL);
      39:         seconds -= (s.tv_sec - f.tv_sec);
      40: /*
      41:  * ONLY way this can happen is if the system time gets set back while we're
      42:  * in the select() call.  In this case return 0 instead of a bogus number.
      43: */
      44:         if  (seconds < 0)
      45:             seconds = 0;
      46:         }
      47:     return(seconds);
      48:     }

#### Defined functions

sleep defined in line 26; used 333 times

- in /usr/include/unistd.h line 70
- in /usr/src/bin/csh/sh.proc.c line 1041
- in /usr/src/bin/disklabel/disklabel.c line 684
- in /usr/src/bin/login/login.c line 292, 600
- in /usr/src/bin/tcsh/sh.c line 1673-1675(2)
- in /usr/src/bin/tcsh/sh.proc.c line 1674
- in /usr/src/bin/tcsh/sh.types.h line 93, 143
- in /usr/src/bin/tcsh/tc.sig.c line 208
- in /usr/src/games/arithmetic.c line 203
- in /usr/src/games/atc/main.c line 250
- in /usr/src/games/backgammon/main.c line 415, 463
- in /usr/src/games/backgammon/move.c line 144
- in /usr/src/games/battlestar/com1.c line 164
- in /usr/src/games/canfield.c line 821
- in /usr/src/games/fortune/fortune.c line 99
- in /usr/src/games/hack/hack.end.c line 236
- in /usr/src/games/hunt/hunt.c line 197, 230, 458
- in /usr/src/games/hunt/playit.c line 277
- in /usr/src/games/pdp/zork/z.c line 162
- in /usr/src/games/phantasia/func0.c line 806
- in /usr/src/games/phantasia/func2.c line 353, 568, 670, 701
- in /usr/src/games/phantasia/phant.h line 147
- in /usr/src/games/rogue/machdep.c line 379, 517
- in /usr/src/games/sail/dr_main.c line 57
- in /usr/src/games/sail/sync.c line 134
- in /usr/src/games/trek/destruct.c line 42, 49-67(5)
- in /usr/src/games/trek/help.c line 97
- in /usr/src/games/trek/lose.c line 45
- in /usr/src/games/trek/ram.c line 43, 55
- in /usr/src/games/trek/snova.c line 91
- in /usr/src/games/trek/warp.c line 103-107(3)
- in /usr/src/games/trek/win.c line 36
- in /usr/src/games/warp/init.c line 516
- in /usr/src/games/warp/play.c line 45-47(2), 55
- in /usr/src/games/warp/score.c line 133, 542
- in /usr/src/games/warp/term.c line 595
- in /usr/src/games/warp/us.c line 250, 259, 273
- in /usr/src/games/warp/util.h line 52-54(2)
- in /usr/src/games/warp/warp.c line 371
- in /usr/src/games/worm.c line 238
- in /usr/src/lib/libc/gen/execvp.c line 56
- in /usr/src/lib/libc/net/rcmd.c line 84
- in /usr/src/lib/libc/net/rexec.c line 53
- in /usr/src/libexec/comsat/comsat.c line 90
- in /usr/src/libexec/ftpd/ftpd.c line 394, 650, 714
- in /usr/src/libexec/getty/main.c line 142, 149, 264
- in /usr/src/libexec/getty/subr.c line 339
- in /usr/src/libexec/rlogind/rlogind.c line 392, 467
- in /usr/src/libexec/tcpd/clean_exit.c line 40
- in /usr/src/libexec/tcpd/percent_x.c line 78
- in /usr/src/libexec/tcpd/tli-sequent.c line 180
- in /usr/src/libexec/tcpd/tli.c line 326
- in /usr/src/libexec/telnetd/telnetd.c line 476
- in /usr/src/libexec/tftpd/tftpd.c line 113
- in /usr/src/local/afio/afio.c line 302, 2713
- in /usr/src/local/trace.c line 45
- in /usr/src/local/zmodem/rbsb.c line 320-322(2)
- in /usr/src/local/zmodem/rz.c line 1451
- in /usr/src/local/zmodem/sz.c line 1732
- in /usr/src/new/OLD/apl/src/a9.c line 42
- in /usr/src/new/OLD/apl/src/aj.c line 246
- in /usr/src/new/PORT/apl/src/a9.c line 42
- in /usr/src/new/PORT/apl/src/aj.c line 246
- in /usr/src/new/PORT/perl.1.0.0/arg.c line 1937-1939(2)
- in /usr/src/new/PORT/perl.1.0.10/arg.c line 1965-1967(2)
- in /usr/src/new/PORT/perl.1.0.16/arg.c line 1989-1991(2)
- in /usr/src/new/crash/if.c line 288
- in /usr/src/new/kermit5.188/ckcfns.c line 1021
- in /usr/src/new/kermit5.188/ckucon.c line 931
- in /usr/src/new/kermit5.188/ckudia.c line 1511, 2045, 2163, 2674
- in /usr/src/new/kermit5.188/ckuscr.c line 183
- in /usr/src/new/kermit5.188/ckutio.c line 2425, 4884, 4912, 4929, 4974, 4989, 5003, 5695
- in /usr/src/new/kermit5.188/ckuus6.c line 932
- in /usr/src/new/nntp/server/main.c line 86
- in /usr/src/new/nntp/server/netaux.c line 128
- in /usr/src/new/notes/src/adnote.c line 44, 54
- in /usr/src/new/notes/src/adresp.c line 38, 76
- in /usr/src/new/notes/src/control.c line 79, 112, 123
- in /usr/src/new/notes/src/dropt.c line 75
- in /usr/src/new/notes/src/index.c line 150, 156
- in /usr/src/new/notes/src/mailit.c line 62, 72, 192, 200
- in /usr/src/new/notes/src/misc.c line 99, 301, 373
- in /usr/src/new/notes/src/newsdump.c line 267, 519
- in /usr/src/new/notes/src/note.c line 72
- in /usr/src/new/notes/src/readem.c line 768, 774
- in /usr/src/new/rcs/src/snoop.c line 91
- in /usr/src/new/rn/init.c line 276
- in /usr/src/new/rn/kfile.c line 270
- in /usr/src/new/rn/ng.c line 335, 352
- in /usr/src/new/rn/rcstuff.c line 302
- in /usr/src/new/rn/term.c line 560
- in /usr/src/old/cu/cu.c line 364
- in /usr/src/old/dump/dumptape.c line 96, 104, 218
- in /usr/src/sbin/dump/dumptape.c line 164, 171, 270
- in /usr/src/sbin/fsck/utilities.c line 326
- in /usr/src/sbin/init/init.c line 162, 181-184(2), 223, 540, 686, 739
- in /usr/src/sbin/quotacheck/preen.c line 114, 154, 168
- in /usr/src/sbin/reboot/reboot.c line 116, 124-127(2), 143, 149
- in /usr/src/sbin/routed/startup.c line 150
- in /usr/src/sbin/shutdown/shutdown.c line 247, 278
- in /usr/src/ucb/PORT/pascal/utilities/px_header.c line 121
- in /usr/src/ucb/PORT/systat/vmstat.c line 333
- in /usr/src/ucb/error/errormain.c line 220
- in /usr/src/ucb/ex/ex_vops3.c line 377
- in /usr/src/ucb/ftp/ftp.c line 1415
- in /usr/src/ucb/leave.c line 180
- in /usr/src/ucb/more/more.c line 1342
- in /usr/src/ucb/rlogin.c line 207
- in /usr/src/ucb/sendbug/bugfiler.c line 128
- in /usr/src/ucb/tail.c line 235
- in /usr/src/ucb/telnet.c line 795
- in /usr/src/ucb/tn3270/tn3270.c line 576
- in /usr/src/ucb/tset/tset.c line 817
- in /usr/src/ucb/vmstat.c line 434
- in /usr/src/usr.bin/iostat.c line 219
- in /usr/src/usr.bin/learn/makpipe.c line 27
- in /usr/src/usr.bin/roff/common_source/n2.c line 186
- in /usr/src/usr.bin/sleep.c line 21
- in /usr/src/usr.bin/tip/aculib/biz22.c line 96
- in /usr/src/usr.bin/tip/aculib/biz31.c line 93, 204, 211
- in /usr/src/usr.bin/tip/aculib/courier.c line 51, 84, 240, 256-258(2), 264
- in /usr/src/usr.bin/tip/aculib/df.c line 70, 88
- in /usr/src/usr.bin/tip/aculib/dn11.c line 52, 97, 106
- in /usr/src/usr.bin/tip/aculib/hayes.c line 70, 112, 220, 232, 242, 266
- in /usr/src/usr.bin/tip/aculib/penril.c line 197, 206, 221
- in /usr/src/usr.bin/tip/aculib/v3451.c line 44, 111
- in /usr/src/usr.bin/tip/aculib/v831.c line 58, 107, 127, 192
- in /usr/src/usr.bin/tip/aculib/ventel.c line 196, 207, 218
- in /usr/src/usr.bin/tip/cmds.c line 274, 619, 758
- in /usr/src/usr.bin/tip/tip.c line 329
- in /usr/src/usr.bin/uucp/acucntrl.c line 285, 383, 407
- in /usr/src/usr.bin/uucp/aculib/att2224.c line 146-151(2)
- in /usr/src/usr.bin/uucp/aculib/cds224.c line 84, 106
- in /usr/src/usr.bin/uucp/aculib/df12.c line 144-151(3)
- in /usr/src/usr.bin/uucp/aculib/df2.c line 71, 78, 91, 142
- in /usr/src/usr.bin/uucp/aculib/dn.c line 71, 89, 140
- in /usr/src/usr.bin/uucp/aculib/hys.c line 167-186(6)
- in /usr/src/usr.bin/uucp/aculib/hys24.c line 67, 110, 119-121(2)
- in /usr/src/usr.bin/uucp/aculib/hysq.c line 136-143(3), 152
- in /usr/src/usr.bin/uucp/aculib/mic.c line 66, 79
- in /usr/src/usr.bin/uucp/aculib/nov.c line 99-106(3), 115
- in /usr/src/usr.bin/uucp/aculib/pen.c line 59, 99
- in /usr/src/usr.bin/uucp/aculib/rvmacs.c line 91, 102, 124, 177
- in /usr/src/usr.bin/uucp/aculib/sy.c line 67, 83, 100, 157
- in /usr/src/usr.bin/uucp/aculib/va212.c line 122
- in /usr/src/usr.bin/uucp/aculib/va820.c line 75, 103
- in /usr/src/usr.bin/uucp/aculib/vad.c line 71, 88, 107, 128
- in /usr/src/usr.bin/uucp/aculib/vent.c line 56, 96
- in /usr/src/usr.bin/uucp/aculib/vmacs.c line 46, 154
- in /usr/src/usr.bin/uucp/cico.c line 454, 490, 673, 685, 693
- in /usr/src/usr.bin/uucp/conn.c line 445, 693, 752, 1096
- in /usr/src/usr.bin/uucp/fio.c line 108
- in /usr/src/usr.bin/uucp/gename.c line 37
- in /usr/src/usr.bin/uucp/gnxseq.c line 38
- in /usr/src/usr.bin/uucp/ulockf.c line 66
- in /usr/src/usr.bin/uucp/xqt.c line 110
- in /usr/src/usr.lib/libU77/sleep_.c line 21
- in /usr/src/usr.lib/libident/ident-tester.c line 242
- in /usr/src/usr.lib/libident/lookup-tester.c line 70
- in /usr/src/usr.lib/libmp/util.c line 43
- in /usr/src/usr.sbin/cron/cron.c line 225
- in /usr/src/usr.sbin/edquota/edquota.c line 156, 203, 214, 325
- in /usr/src/usr.sbin/inetd/inetd.c line 320, 390
- in /usr/src/usr.sbin/lpr/common.c line 110
- in /usr/src/usr.sbin/lpr/lpq.c line 122
- in /usr/src/usr.sbin/lpr/printjob.c line 739, 971, 1130, 1155
- in /usr/src/usr.sbin/lpr/rmjob.c line 133
- in /usr/src/usr.sbin/ntp/read_psti.c line 73
- in /usr/src/usr.sbin/sendmail.MX/aux/bbn_daemon.c line 92, 114, 147
- in /usr/src/usr.sbin/sendmail/aux/4.1a_daemon.c line 90, 123, 188, 204, 234
- in /usr/src/usr.sbin/sendmail/aux/bbn_daemon.c line 92, 114, 147
- in /usr/src/usr.sbin/timed/master.c line 519
- in /usr/src/usr.sbin/trpt/trpt.c line 216

Last modified: 1997-09-26 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 746 |