diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-06-25 16:11:12 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-06-25 16:11:12 +0000 |
commit | f17a5f1e82546e67c5aa1f4b2efd0203ff1f19b2 (patch) | |
tree | 21e3209e20ed7219401a470f92219e065fc0fb61 /tmux.c | |
parent | bfa46e8f91aa79fdd6358927dda6ba74f28a45d7 (diff) | |
download | rtmux-f17a5f1e82546e67c5aa1f4b2efd0203ff1f19b2.tar.gz rtmux-f17a5f1e82546e67c5aa1f4b2efd0203ff1f19b2.tar.bz2 rtmux-f17a5f1e82546e67c5aa1f4b2efd0203ff1f19b2.zip |
If getcwd() fails, use the user's home directory, or /, instead of failing with
an error.
Diffstat (limited to 'tmux.c')
-rw-r--r-- | tmux.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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> @@ -387,8 +387,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); |