Implement suggestion from Adam Slattery, (don't default to killing closing bug #1190.
[oweals/busybox.git] / hostname.c
index 75e4d2e574e9cc635dca8112f745e33badf1af05..d878515097fc1afc0bd86375a41fb632cdbf0fea 100644 (file)
@@ -1,6 +1,6 @@
 /* vi: set sw=4 ts=4: */
 /*
- * $Id: hostname.c,v 1.28 2001/05/16 15:40:48 kraai Exp $
+ * $Id: hostname.c,v 1.30 2001/06/26 02:06:08 bug1 Exp $
  * Mini hostname implementation for busybox
  *
  * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -23,7 +23,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
-#include "busybox.h"
 #include <errno.h>
 #include <arpa/inet.h>
 #include <netdb.h>
@@ -31,6 +30,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include "busybox.h"
 
 static void do_sethostname(char *s, int isfile)
 {
@@ -49,10 +49,11 @@ static void do_sethostname(char *s, int isfile)
        } else {
                f = xfopen(s, "r");
                fgets(buf, 255, f);
+#ifdef BB_FEATURE_CLEAN_UP
                fclose(f);
+#endif
                chomp(buf);
-               if (sethostname(buf, strlen(buf)) < 0)
-                       perror_msg_and_die("sethostname");
+               do_sethostname(buf, 0);
        }
 }