diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-06-25 06:54:33 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-06-25 06:54:33 +0000 |
commit | 228c5082b93c3cbed4938f8376bf7953c773c8e3 (patch) | |
tree | cdce74257b6bf72da0031d65d941ebe8cbb1a883 | |
parent | 3a819282f54713d07d84c6b8ca4ddbf48b70e8dc (diff) |
If getcwd() fails, use the user's home directory, or /, instead of failing with
an error.
-rw-r--r-- | usr.bin/tmux/tmux.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c index b2466d034f8..36329665b71 100644 --- a/usr.bin/tmux/tmux.c +++ b/usr.bin/tmux/tmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.c,v 1.10 2009/06/25 06:40:25 nicm Exp $ */ +/* $OpenBSD: tmux.c,v 1.11 2009/06/25 06:54:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -371,8 +371,11 @@ main(int argc, char **argv) &global_options, "default-command", "exec %s -l", shell); if (getcwd(cwd, sizeof cwd) == NULL) { - log_warn("getcwd"); - exit(1); + pw = getpwuid(getuid()); + if (pw->pw_dir != NULL && *pw->pw_dir != '\0') + strlcpy(cwd, pw->pw_dir, sizeof cwd); + else + strlcpy(cwd, "/", sizeof cwd); } options_set_string(&global_options, "default-path", "%s", cwd); |