From 10da95cf3f2fa93a975c530b6dc7e04330d40acb Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 4 Jul 2004 18:01:04 +0000 Subject: (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. --- src/nohup.c | 15 ++++++++++----- 1 file 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; -- cgit v1.2.3-70-g09d2