Date: Wed, 14 Apr 2004 23:03:12 -0700 (PDT) From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 51083 for review Message-ID: <200404150603.i3F63Cav080359@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=51083 Change 51083 by marcel@marcel_nfs on 2004/04/14 23:03:05 close the command file descriptor before we fork/exec gdb(1) and make sure we unlink the (temporary) command file in all normal cases (for now) by registering an atexit() function. Affected files ... .. //depot/projects/gdb/usr.bin/kgdb/main.c#3 edit Differences ... ==== //depot/projects/gdb/usr.bin/kgdb/main.c#3 (text+ko) ==== @@ -35,6 +35,7 @@ #include <errno.h> #include <err.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> @@ -45,6 +46,14 @@ int cmdfile_fd; static void +atexit_unlink_cmdfile(void) +{ + close(cmdfile_fd); /* Is likely closed already. */ + unlink(cmdfile_name); + free(cmdfile_name); +} + +static void mkpipe(int *rd, int *wr) { int f[2]; @@ -62,6 +71,8 @@ int in, out; int f, fmax; + close(cmdfile_fd); + mkpipe(&in, &gdb_in); mkpipe(&gdb_out, &out); @@ -97,6 +108,7 @@ cmdfile_fd = mkstemp(cmdfile_name); if (cmdfile_fd == -1) err(1, "mkstemp(3)"); + atexit(atexit_unlink_cmdfile); if (write(cmdfile_fd, set_prompt, sizeof(set_prompt) - 1) < 0) err(1, "write(2)"); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200404150603.i3F63Cav080359>