mirror of
https://github.com/tmux/tmux.git
synced 2025-01-13 03:48:51 +00:00
Use open(".")/fchdir() to save and restore current directory rather than
getcwd()/chdir().
This commit is contained in:
parent
304ea079d2
commit
3d8a8ea0c6
12
tmux.c
12
tmux.c
@ -127,16 +127,22 @@ areshell(const char *shell)
|
||||
const char*
|
||||
get_full_path(const char *wd, const char *path)
|
||||
{
|
||||
int fd;
|
||||
static char newpath[MAXPATHLEN];
|
||||
char oldpath[MAXPATHLEN];
|
||||
|
||||
if (getcwd(oldpath, sizeof oldpath) == NULL)
|
||||
fd = open(".", O_RDONLY);
|
||||
if (fd == -1)
|
||||
return (NULL);
|
||||
|
||||
if (chdir(wd) != 0)
|
||||
return (NULL);
|
||||
if (realpath(path, newpath) != 0)
|
||||
return (NULL);
|
||||
chdir(oldpath);
|
||||
|
||||
if (fchdir(fd) != 0)
|
||||
chdir("/");
|
||||
close(fd);
|
||||
|
||||
return (newpath);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user