2 * Copyright (c) 1997-2002 Red Hat, Inc. All rights reserved.
4 * This software may be freely redistributed under the terms of the GNU
7 * You should have received a copy of the GNU General Public License
8 * along with this program; if not, write to the Free Software
9 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /* this will be running setgid root, so be careful! */
23 fprintf(stderr, "usage: netreport [-r]\n");
29 int main(int argc, char ** argv) {
31 /* more than long enough for "/var/run/netreport/<pid>\0" */
32 char netreport_name[64];
40 if (argc == 2 && strcmp(argv[1], "-r") == 0) {
47 snprintf(netreport_name, sizeof(netreport_name),
48 "/var/run/netreport/%d", getppid());
50 netreport_file = open(netreport_name,
51 O_EXCL|O_CREAT|O_WRONLY|O_TRUNC|O_NOFOLLOW, 0);
52 if (netreport_file == -1) {
53 if (errno != EEXIST) {
54 perror("Could not create netreport file");
58 close(netreport_file);
61 /* ignore errors; not much we can do, won't hurt anything */
62 unlink(netreport_name);