Work around Linux realpath breakage.

This commit is contained in:
Nicholas Marriott 2007-11-20 12:59:27 +00:00
parent 14627f5421
commit da21ac965d

17
tmux.c
View File

@ -1,4 +1,4 @@
/* $Id: tmux.c,v 1.41 2007-11-16 21:12:31 nicm Exp $ */
/* $Id: tmux.c,v 1.42 2007-11-20 12:59:27 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -219,8 +219,19 @@ main(int argc, char **argv)
"%s/%s-%lu", _PATH_TMP, __progname, (u_long) getuid());
}
if (realpath(path, rpath) == NULL) {
log_warn("%s", path);
exit(1);
if (errno != ENOENT) {
log_warn("%s", path);
exit(1);
}
/*
* Linux appears to fill in the buffer fine but then returns
* ENOENT if the file doesn't exist. But since it returns an
* error, we can't rely on the buffer. Grr.
*/
if (strlcpy(rpath, path, sizeof rpath) >= sizeof rpath) {
log_warnx("%s: %s", path, strerror(ENAMETOOLONG));
exit(1);
}
}
xfree(path);