PERFORCE change 51083 for review
Marcel Moolenaar
marcel at FreeBSD.org
Wed Apr 14 23:03:13 PDT 2004
http://perforce.freebsd.org/chv.cgi?CH=51083
Change 51083 by marcel at 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)");
}
More information about the p4-projects
mailing list