hardcoded /tmp instead of TMPDIR
- From: Oskar Liljeblad <oskar osk mine nu>
- To: mc-devel gnome org
- Subject: hardcoded /tmp instead of TMPDIR
- Date: Thu, 5 Sep 2002 22:16:55 +0200
According to the bug report at
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=142179&repeatmerged=yes
MC does not use $TMP. (The reporter must have meant $TMPDIR.)
I did a grep (with MC of course :) for files with /tmp and
found one place in subshell.c. This patch ought to fix it. I tested
it (with tcsh as shell of course) and it works fine.
Oskar Liljeblad (oskar osk mine nu)
--- subshell.c.orig 2002-09-05 21:59:39.000000000 +0200
+++ subshell.c 2002-09-05 22:12:31.000000000 +0200
@@ -337,9 +337,8 @@
int pty_slave = -1;
/* Braindead tcsh can't redirect output to a file descriptor? */
- char tcsh_fifo[sizeof "/tmp/mc.pipe.1234567890"];
+ char *tcsh_fifo = NULL;
-
#ifdef SYNC_PTY_SIDES
/* Used to wait for a SIGUSR1 signal from the subprocess */
sigset_t sigusr1_mask, old_mask;
@@ -401,11 +400,20 @@
if (subshell_type == TCSH)
{
- g_snprintf (tcsh_fifo, sizeof (tcsh_fifo), "/tmp/mc.pipe.%d", getpid ());
+ char *tmpdir;
+
+ tmpdir = getenv("TMPDIR");
+ if (!tmpdir) {
+ tmpdir = TMPDIR_DEFAULT;
+ }
+
+ tcsh_fifo = g_strdup_printf("%s/mc.pipe.%d", tmpdir, getpid ());
+ printf("--> %s <--\r\n", tcsh_fifo);
if (mkfifo (tcsh_fifo, 0600) == -1)
{
perror (__FILE__": mkfifo");
use_subshell = FALSE;
+ g_free (tcsh_fifo);
return;
}
@@ -417,6 +425,7 @@
fprintf (stderr, _("Couldn't open named pipe %s\n"), tcsh_fifo);
perror (__FILE__": open");
use_subshell = FALSE;
+ g_free (tcsh_fifo);
return;
}
}
@@ -511,6 +520,7 @@
"set echo_style=both;"
"alias precmd 'echo $cwd:q >>%s;kill -STOP $$'\n",
tcsh_fifo);
+ g_free (tcsh_fifo);
write_it:
write (subshell_pty, precmd, strlen (precmd));
@@ -704,10 +714,17 @@
if (quit && subshell_type == TCSH)
{
+ char *tmpdir;
+
+ tmpdir = getenv("TMPDIR");
+ if (!tmpdir) {
+ tmpdir = TMPDIR_DEFAULT;
+ }
+
/* We abuse of pty_buffer here, but it doesn't matter at this stage */
- g_snprintf (pty_buffer, pty_buffer_size, "/tmp/mc.pipe.%d", getpid ());
+ g_snprintf (pty_buffer, pty_buffer_size, "%s/mc.pipe.%d", tmpdir, getpid ());
if (unlink (pty_buffer) == -1)
- perror (__FILE__": couldn't remove named pipe /tmp/mc.pipe.NNN");
+ perror (__FILE__": couldn't remove named pipe mc.pipe.NNN from tmpdir");
}
g_free (subshell_prompt);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]