diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-11-20 12:59:27 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-11-20 12:59:27 +0000 |
commit | da21ac965d4d6d3a136cf574d396f19bd2941efd (patch) | |
tree | 2d4459d7dbf5d8cf98c8fc1d8c4f48d5dfd4c669 /tmux.c | |
parent | 14627f5421981279775c6a35f09ff2740ba057d8 (diff) | |
download | rtmux-da21ac965d4d6d3a136cf574d396f19bd2941efd.tar.gz rtmux-da21ac965d4d6d3a136cf574d396f19bd2941efd.tar.bz2 rtmux-da21ac965d4d6d3a136cf574d396f19bd2941efd.zip |
Work around Linux realpath breakage.
Diffstat (limited to 'tmux.c')
-rw-r--r-- | tmux.c | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -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); |