Ticket #4535: mc-tmp-pid.patch

File mc-tmp-pid.patch, 1.3 KB (added by eugenesan, 8 months ago)

Add process ID to the temporary directory name

  • lib/vfs/interface.c

    diff --git a/lib/vfs/interface.c b/lib/vfs/interface.c
    index 545dd1d46..82bc2d55e 100644
    a b mc_mkstemps (vfs_path_t ** pname_vpath, const char *prefix, const char *suffix) 
    762762/* --------------------------------------------------------------------------------------------- */ 
    763763/** 
    764764 * Return the directory where mc should keep its temporary files. 
    765  * This directory is (in Bourne shell terms) "${TMPDIR=/tmp}/mc-$USER" 
     765 * This directory is (in Bourne shell terms) "${TMPDIR=/tmp}/mc-$USER-$PID" 
    766766 * When called the first time, the directory is created if needed. 
    767767 * The first call should be done early, since we are using fprintf() 
    768768 * and not message() to report possible problems. 
    mc_tmpdir (void) 
    793793 
    794794    pwd = getpwuid (getuid ()); 
    795795    if (pwd != NULL) 
    796         g_snprintf (buffer, sizeof (buffer), "%s/mc-%s", sys_tmp, pwd->pw_name); 
     796        g_snprintf (buffer, sizeof (buffer), "%s/mc-%s-%lu", sys_tmp, pwd->pw_name, (unsigned long) getpid ()); 
    797797    else 
    798         g_snprintf (buffer, sizeof (buffer), "%s/mc-%lu", sys_tmp, (unsigned long) getuid ()); 
     798        g_snprintf (buffer, sizeof (buffer), "%s/mc-%lu-%lu", sys_tmp, (unsigned long) getuid (), (unsigned long) getpid ()); 
    799799 
    800800    canonicalize_pathname (buffer); 
    801801