| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | | - |
| 12 | | - |
| 13 | | - |
| 14 | | - |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | | - |
| 20 | | - |
| 21 | #include "config.h" | - |
| 22 | | - |
| 23 | #include "bashtypes.h" | - |
| 24 | | - |
| 25 | #if defined (TIME_WITH_SYS_TIME) | - |
| 26 | # include <sys/time.h> | - |
| 27 | # include <time.h> | - |
| 28 | #else | - |
| 29 | # if defined (HAVE_SYS_TIME_H) | - |
| 30 | # include <sys/time.h> | - |
| 31 | # else | - |
| 32 | # include <time.h> | - |
| 33 | # endif | - |
| 34 | #endif | - |
| 35 | | - |
| 36 | #if defined (HAVE_UNISTD_H) | - |
| 37 | #include <unistd.h> | - |
| 38 | #endif | - |
| 39 | | - |
| 40 | #include <errno.h> | - |
| 41 | #if !defined (errno) | - |
| 42 | extern int errno; | - |
| 43 | #endif /* !errno */ | - |
| 44 | | - |
| 45 | #if defined (HAVE_SELECT) | - |
| 46 | # include "posixselect.h" | - |
| 47 | # include "quit.h" | - |
| 48 | # include "trap.h" | - |
| 49 | # include "stat-time.h" | - |
| 50 | #endif | - |
| 51 | | - |
| 52 | | - |
| 53 | | - |
| 54 | #if defined (HAVE_SETITIMER) | - |
| 55 | unsigned int | - |
| 56 | falarm(secs, usecs) | - |
| 57 | unsigned int secs, usecs; | - |
| 58 | { | - |
| 59 | struct itimerval it, oit; | - |
| 60 | | - |
| 61 | it.it_interval.tv_sec = 0; | - |
| 62 | it.it_interval.tv_usec = 0; | - |
| 63 | | - |
| 64 | it.it_value.tv_sec = secs; | - |
| 65 | it.it_value.tv_usec = usecs; | - |
| 66 | | - |
| 67 | if (setitimer(ITIMER_REAL, &it, &oit) < 0)| TRUE | never evaluated | | FALSE | evaluated 4 times by 1 test |
| 0-4 |
| 68 | return (-1); never executed: return (-1); | 0 |
| 69 | | - |
| 70 | | - |
| 71 | if (oit.it_value.tv_usec)| TRUE | evaluated 1 time by 1 test | | FALSE | evaluated 3 times by 1 test |
| 1-3 |
| 72 | oit.it_value.tv_sec++;executed 1 time by 1 test: oit.it_value.tv_sec++; | 1 |
| 73 | return (oit.it_value.tv_sec);executed 4 times by 1 test: return (oit.it_value.tv_sec); | 4 |
| 74 | } | - |
| 75 | #else | - |
| 76 | int | - |
| 77 | falarm (secs, usecs) | - |
| 78 | unsigned int secs, usecs; | - |
| 79 | { | - |
| 80 | if (secs == 0 && usecs == 0) | - |
| 81 | return (alarm (0)); | - |
| 82 | | - |
| 83 | if (secs == 0 || usecs >= 500000) | - |
| 84 | { | - |
| 85 | secs++; | - |
| 86 | usecs = 0; | - |
| 87 | } | - |
| 88 | return (alarm (secs)); | - |
| 89 | } | - |
| 90 | #endif /* !HAVE_SETITIMER */ | - |
| 91 | | - |
| 92 | | - |
| 93 | | - |
| 94 | | - |
| 95 | #if defined (HAVE_TIMEVAL) && (defined (HAVE_SELECT) || defined (HAVE_PSELECT)) | - |
| 96 | int | - |
| 97 | fsleep(sec, usec) | - |
| 98 | unsigned int sec, usec; | - |
| 99 | { | - |
| 100 | int e, r; | - |
| 101 | sigset_t blocked_sigs, prevmask; | - |
| 102 | #if defined (HAVE_PSELECT) | - |
| 103 | struct timespec ts; | - |
| 104 | #else | - |
| 105 | struct timeval tv; | - |
| 106 | #endif | - |
| 107 | | - |
| 108 | sigemptyset (&blocked_sigs); | - |
| 109 | # if defined (SIGCHLD) | - |
| 110 | sigaddset (&blocked_sigs, SIGCHLD); | - |
| 111 | # endif | - |
| 112 | | - |
| 113 | #if defined (HAVE_PSELECT) | - |
| 114 | ts.tv_sec = sec; | - |
| 115 | ts.tv_nsec = usec * 1000; | - |
| 116 | #else | - |
| 117 | sigemptyset (&prevmask); | - |
| 118 | tv.tv_sec = sec; | - |
| 119 | tv.tv_usec = usec; | - |
| 120 | #endif /* !HAVE_PSELECT */ | - |
| 121 | | - |
| 122 | do | - |
| 123 | { | - |
| 124 | #if defined (HAVE_PSELECT) | - |
| 125 | r = pselect(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &ts, &blocked_sigs); | - |
| 126 | #else | - |
| 127 | sigprocmask (SIG_SETMASK, &blocked_sigs, &prevmask); | - |
| 128 | r = select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &tv); | - |
| 129 | sigprocmask (SIG_SETMASK, &prevmask, NULL); | - |
| 130 | #endif | - |
| 131 | e = errno; | - |
| 132 | if (r < 0 && errno == EINTR)| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 133 | QUIT; never executed: termsig_handler (terminating_signal); never executed: throw_to_top_level (); never executed: end of block | TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 134 | errno = e; | - |
| 135 | } never executed: end of block | 0 |
| 136 | while (r < 0 && errno == EINTR);| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 137 | | - |
| 138 | return r; never executed: return r; | 0 |
| 139 | } | - |
| 140 | #else /* !HAVE_TIMEVAL || !HAVE_SELECT */ | - |
| 141 | int | - |
| 142 | fsleep(sec, usec) | - |
| 143 | long sec, usec; | - |
| 144 | { | - |
| 145 | if (usec >= 500000) | - |
| 146 | sec++; | - |
| 147 | return (sleep(sec)); | - |
| 148 | } | - |
| 149 | #endif /* !HAVE_TIMEVAL || !HAVE_SELECT */ | - |
| | |