version 1.79, 2006/06/01 15:59:31 |
version 1.80, 2006/06/01 18:04:08 |
Line 241 static void jiggle(int), jiggle_flush(in |
|
Line 241 static void jiggle(int), jiggle_flush(in |
|
static void gethost(const char *, const char *, |
static void gethost(const char *, const char *, |
struct sockaddr_in *, char *, int); |
struct sockaddr_in *, char *, int); |
static void usage(void); |
static void usage(void); |
|
#if defined(SIGINFO) && defined(NOKERNINFO) |
|
static int fgtty(int, struct termios *); |
|
#endif |
|
|
int |
int |
main(int argc, char *argv[]) |
main(int argc, char *argv[]) |
Line 638 main(int argc, char *argv[]) |
|
Line 640 main(int argc, char *argv[]) |
|
(void)signal(SIGINT, prefinish); |
(void)signal(SIGINT, prefinish); |
|
|
#if defined(SIGINFO) && defined(NOKERNINFO) |
#if defined(SIGINFO) && defined(NOKERNINFO) |
if (tcgetattr(STDIN_FILENO, &ts) != -1) { |
if (fgtty(STDIN_FILENO, &ts) != -1) { |
pid_t ttypgrp = tcgetpgrp(STDIN_FILENO); |
reset_kerninfo = !(ts.c_lflag & NOKERNINFO); |
pid_t pgrp = getpgid(0); |
ts.c_lflag |= NOKERNINFO; |
if (ttypgrp != -1 && pgrp != -1 && ttypgrp == pgrp) { |
(void)tcsetattr(STDIN_FILENO, TCSANOW, &ts); |
reset_kerninfo = !(ts.c_lflag & NOKERNINFO); |
|
ts.c_lflag |= NOKERNINFO; |
|
(void)tcsetattr(STDIN_FILENO, TCSANOW, &ts); |
|
} |
|
} |
} |
#endif |
#endif |
|
|
Line 1344 prefinish(int dummy) |
|
Line 1342 prefinish(int dummy) |
|
npackets = ntransmitted; |
npackets = ntransmitted; |
} |
} |
|
|
|
#if defined(SIGINFO) && defined(NOKERNINFO) |
|
static int |
|
fgtty(int fd, struct termios *ts) |
|
{ |
|
pid_t ttypgrp, pgrp; |
|
|
|
if (tcgetattr(fd, ts) == -1) |
|
return -1; |
|
if ((ttypgrp = tcgetpgrp(fd)) == -1) |
|
return -1; |
|
if ((pgrp = getpgid(0)) == -1) |
|
return -1; |
|
|
|
return ttypgrp == pgrp ? 0 : -1; |
|
} |
|
#endif |
|
|
/* |
/* |
* Print statistics and give up. |
* Print statistics and give up. |
Line 1355 finish(int dummy) |
|
Line 1369 finish(int dummy) |
|
#if defined(SIGINFO) && defined(NOKERNINFO) |
#if defined(SIGINFO) && defined(NOKERNINFO) |
struct termios ts; |
struct termios ts; |
|
|
|
/* |
|
* Note that the following will suspend the ping program |
|
* if it is in the background. We could have used fgtty() |
|
* to avoid this, but then we would fail to restore the |
|
* tty setting. So we prefer to suspend here. XXX: NOKERNINFO |
|
* should prolly be a signal struct attribute |
|
*/ |
if (reset_kerninfo && tcgetattr(STDIN_FILENO, &ts) != -1) { |
if (reset_kerninfo && tcgetattr(STDIN_FILENO, &ts) != -1) { |
ts.c_lflag &= ~NOKERNINFO; |
ts.c_lflag &= ~NOKERNINFO; |
(void)tcsetattr(STDIN_FILENO, TCSANOW, &ts); |
(void)tcsetattr(STDIN_FILENO, TCSANOW, &ts); |