Move sed over to the generic llist_t for append. Saves about 90 bytes.
[oweals/busybox.git] / loginutils / getty.c
index db9a150e01f321ecfbbd99e7721c274d523c4b2f..24d579f75e6235703331fc7cc1190d956c21d67c 100644 (file)
@@ -21,7 +21,7 @@
 #include <sys/ioctl.h>
 #include <errno.h>
 #include <sys/stat.h>
-#include <sys/signal.h>
+#include <signal.h>
 #include <fcntl.h>
 #include <stdarg.h>
 #include <ctype.h>
@@ -110,15 +110,6 @@ extern void updwtmp(const char *filename, const struct utmp *ut);
 #define TCGETA  TCGETS
 #define TCSETA  TCSETS
 #define TCSETAW TCSETSW
-#endif
-
- /*
-  * This program tries to not use the standard-i/o library.  This keeps the
-  * executable small on systems that do not have shared libraries (System V
-  * Release <3).
-  */
-#ifndef BUFSIZ
-#define BUFSIZ          1024
 #endif
 
  /*
@@ -234,7 +225,7 @@ static void termio_final(struct options *op, struct termio *tp,
                                struct chardata *cp);
 static int caps_lock(const char *s);
 static int bcode(const char *s);
-static void error(const char *fmt, ...) __attribute__ ((noreturn));
+static void error(const char *fmt, ...) ATTRIBUTE_NORETURN;
 
 #ifdef  SYSV_STYLE
 #ifdef CONFIG_FEATURE_UTMP
@@ -537,12 +528,11 @@ static void open_tty(char *tty, struct termio *tp, int local)
 
                /* Open the tty as standard input. */
 
+               close(0);
                debug("open(2)\n");
                fd = open(tty, O_RDWR | O_NONBLOCK, 0);
-               if (dup2(fd, STDIN_FILENO) == -1)
+               if (fd != 0)
                        error("/dev/%s: cannot open as standard input: %m", tty);
-               close(fd);
-
        } else {
 
                /*
@@ -744,12 +734,12 @@ static void next_speed(struct termio *tp, struct options *op)
 /* return NULL on failure, logname on success */
 static char *get_logname(struct options *op, struct chardata *cp, struct termio *tp)
 {
-       static char logname[BUFSIZ];
+#define logname bb_common_bufsiz1
        char *bp;
-       char c;                                         /* input character, full eight bits */
-       char ascval;                            /* low 7 bits of input character */
-       int bits;                                       /* # of "1" bits per character */
-       int mask;                                       /* mask with 1 bit up */
+       char c;                         /* input character, full eight bits */
+       char ascval;                    /* low 7 bits of input character */
+       int bits;                       /* # of "1" bits per character */
+       int mask;                       /* mask with 1 bit up */
        static char *erase[] = {        /* backspace-space-backspace */
                "\010\040\010",                 /* space parity */
                "\010\040\010",                 /* odd parity */