summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2004-07-04 18:01:04 +0000
committerJim Meyering <jim@meyering.net>2004-07-04 18:01:04 +0000
commit10da95cf3f2fa93a975c530b6dc7e04330d40acb (patch)
treea5ebf918a6ee48c8b7180f482d1cebc9c5c11d7b
parentcc4105f09590f3619a2190a7ce6ccfde5734e681 (diff)
downloadcoreutils-10da95cf3f2fa93a975c530b6dc7e04330d40acb.tar.xz
(main): Don't pass NULL first argument to path_concat.
This cleans up the semantics a bit, as we no longer try to open the same file twice.
-rw-r--r--src/nohup.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/nohup.c b/src/nohup.c
index 88deba4d5..1bc778154 100644
--- a/src/nohup.c
+++ b/src/nohup.c
@@ -109,19 +109,24 @@ main (int argc, char **argv)
char const *file = "nohup.out";
int flags = O_CREAT | O_WRONLY | O_APPEND;
mode_t mode = S_IRUSR | S_IWUSR;
- int saved_errno;
fd = open (file, flags, mode);
if (fd == -1)
{
- saved_errno = errno;
- in_home = path_concat (getenv ("HOME"), file, NULL);
- fd = open (in_home, flags, mode);
+ int saved_errno = errno;
+ char const *home = getenv ("HOME");
+ if (home)
+ {
+ in_home = path_concat (home, file, NULL);
+ fd = open (in_home, flags, mode);
+ }
if (fd == -1)
{
int saved_errno2 = errno;
error (0, saved_errno, _("failed to open %s"), quote (file));
- error (0, saved_errno2, _("failed to open %s"), quote (in_home));
+ if (in_home)
+ error (0, saved_errno2, _("failed to open %s"),
+ quote (in_home));
exit (NOHUP_FAILURE);
}
file = in_home;