Deleted Added
full compact
util.c (50471) util.c (90111)
1/*-
2 * Copyright (c) 1991, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35#if 0
36static char sccsid[] = "@(#)util.c 8.3 (Berkeley) 4/2/94";
37#endif
38static const char rcsid[] =
1/*-
2 * Copyright (c) 1991, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35#if 0
36static char sccsid[] = "@(#)util.c 8.3 (Berkeley) 4/2/94";
37#endif
38static const char rcsid[] =
39 "$FreeBSD: head/bin/stty/util.c 50471 1999-08-27 23:15:48Z peter $";
39 "$FreeBSD: head/bin/stty/util.c 90111 2002-02-02 06:50:57Z imp $";
40#endif /* not lint */
41
42#include <sys/types.h>
43#include <sys/stat.h>
44
45#include <err.h>
46#include <stdio.h>
47#include <stdlib.h>

--- 4 unchanged lines hidden (view full) ---

52
53/*
54 * Gross, but since we're changing the control descriptor from 1 to 0, most
55 * users will be probably be doing "stty > /dev/sometty" by accident. If 1
56 * and 2 are both ttys, but not the same, assume that 1 was incorrectly
57 * redirected.
58 */
59void
40#endif /* not lint */
41
42#include <sys/types.h>
43#include <sys/stat.h>
44
45#include <err.h>
46#include <stdio.h>
47#include <stdlib.h>

--- 4 unchanged lines hidden (view full) ---

52
53/*
54 * Gross, but since we're changing the control descriptor from 1 to 0, most
55 * users will be probably be doing "stty > /dev/sometty" by accident. If 1
56 * and 2 are both ttys, but not the same, assume that 1 was incorrectly
57 * redirected.
58 */
59void
60checkredirect()
60checkredirect(void)
61{
62 struct stat sb1, sb2;
63
64 if (isatty(STDOUT_FILENO) && isatty(STDERR_FILENO) &&
65 !fstat(STDOUT_FILENO, &sb1) && !fstat(STDERR_FILENO, &sb2) &&
66 (sb1.st_rdev != sb2.st_rdev))
67warnx("stdout appears redirected, but stdin is the control descriptor");
68}
61{
62 struct stat sb1, sb2;
63
64 if (isatty(STDOUT_FILENO) && isatty(STDERR_FILENO) &&
65 !fstat(STDOUT_FILENO, &sb1) && !fstat(STDERR_FILENO, &sb2) &&
66 (sb1.st_rdev != sb2.st_rdev))
67warnx("stdout appears redirected, but stdin is the control descriptor");
68}