Deleted Added
full compact
nohup.c (98971) nohup.c (99984)
1/*
2 * Copyright (c) 1989, 1993
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

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

37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41#if 0
42static char sccsid[] = "@(#)nohup.c 8.1 (Berkeley) 6/6/93";
43#endif
44static const char rcsid[] =
1/*
2 * Copyright (c) 1989, 1993
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

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

37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41#if 0
42static char sccsid[] = "@(#)nohup.c 8.1 (Berkeley) 6/6/93";
43#endif
44static const char rcsid[] =
45 "$FreeBSD: head/usr.bin/nohup/nohup.c 98971 2002-06-28 09:34:46Z tjr $";
45 "$FreeBSD: head/usr.bin/nohup/nohup.c 99984 2002-07-14 18:23:22Z alfred $";
46#endif /* not lint */
47
48#include <sys/param.h>
49#include <sys/stat.h>
50
51#include <err.h>
52#include <errno.h>
53#include <fcntl.h>

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

66 * 126 - If the utility was found, but failed to execute.
67 * 127 - If any other error occurred.
68 */
69#define EXIT_NOEXEC 126
70#define EXIT_NOTFOUND 127
71#define EXIT_MISC 127
72
73int
46#endif /* not lint */
47
48#include <sys/param.h>
49#include <sys/stat.h>
50
51#include <err.h>
52#include <errno.h>
53#include <fcntl.h>

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

66 * 126 - If the utility was found, but failed to execute.
67 * 127 - If any other error occurred.
68 */
69#define EXIT_NOEXEC 126
70#define EXIT_NOTFOUND 127
71#define EXIT_MISC 127
72
73int
74main(argc, argv)
75 int argc;
76 char *argv[];
74main(int argc, char *argv[])
77{
78 int exit_status;
79
80 while (getopt(argc, argv, "") != -1)
81 usage();
82 argc -= optind;
83 argv += optind;
84 if (argc < 1)

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

93 (void)signal(SIGHUP, SIG_IGN);
94
95 execvp(*argv, argv);
96 exit_status = (errno == ENOENT) ? EXIT_NOTFOUND : EXIT_NOEXEC;
97 err(exit_status, "%s", argv[0]);
98}
99
100static void
75{
76 int exit_status;
77
78 while (getopt(argc, argv, "") != -1)
79 usage();
80 argc -= optind;
81 argv += optind;
82 if (argc < 1)

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

91 (void)signal(SIGHUP, SIG_IGN);
92
93 execvp(*argv, argv);
94 exit_status = (errno == ENOENT) ? EXIT_NOTFOUND : EXIT_NOEXEC;
95 err(exit_status, "%s", argv[0]);
96}
97
98static void
101dofile()
99dofile(void)
102{
103 int fd;
104 char path[MAXPATHLEN];
105 const char *p;
106
107 /*
108 * POSIX mandates if the standard output is a terminal, the standard
109 * output is appended to nohup.out in the working directory. Failing

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

127
128dupit:
129 if (dup2(fd, STDOUT_FILENO) == -1)
130 err(EXIT_MISC, NULL);
131 (void)fprintf(stderr, "appending output to %s\n", p);
132}
133
134static void
100{
101 int fd;
102 char path[MAXPATHLEN];
103 const char *p;
104
105 /*
106 * POSIX mandates if the standard output is a terminal, the standard
107 * output is appended to nohup.out in the working directory. Failing

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

125
126dupit:
127 if (dup2(fd, STDOUT_FILENO) == -1)
128 err(EXIT_MISC, NULL);
129 (void)fprintf(stderr, "appending output to %s\n", p);
130}
131
132static void
135usage()
133usage(void)
136{
137 (void)fprintf(stderr, "usage: nohup [--] utility [arguments]\n");
138 exit(EXIT_MISC);
139}
134{
135 (void)fprintf(stderr, "usage: nohup [--] utility [arguments]\n");
136 exit(EXIT_MISC);
137}