* Copyright (c) 1991 The Regents of the University of California.
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)util.c 5.2 (Berkeley) %G%";
* Gross, but since we're changing the control descriptor from 1 to 0, most
* users will be probably be doing "stty > /dev/sometty" by accident. If 1
* and 2 are both ttys, but not the same, assume that 1 was incorrectly
if (isatty(STDOUT_FILENO
) && isatty(STDERR_FILENO
) &&
!fstat(STDOUT_FILENO
, &sb1
) && !fstat(STDERR_FILENO
, &sb2
) &&
(sb1
.st_rdev
!= sb2
.st_rdev
))
warn("stdout appears redirected, but stdin is the control descriptor");
err(const char *fmt
, ...)
(void)fprintf(stderr
, "stty: ");
(void)vfprintf(stderr
, fmt
, ap
);
(void)fprintf(stderr
, "\n");
warn(const char *fmt
, ...)
(void)fprintf(stderr
, "stty: ");
(void)vfprintf(stderr
, fmt
, ap
);
(void)fprintf(stderr
, "\n");