-int getty_main(int argc, char **argv)
-{
- char *logname = NULL; /* login name, given to /bin/login */
- struct chardata chardata; /* set by get_logname() */
- struct termio termio; /* terminal mode bits */
- static struct options options = {
- 0, /* show /etc/issue (SYSV_STYLE) */
- 0, /* no timeout */
- _PATH_LOGIN, /* default login program */
- "tty1", /* default tty line */
- "", /* modem init string */
-#ifdef ISSUE
- ISSUE, /* default issue file */
-#else
- NULL,
-#endif
- 0, /* no baud rates known yet */
- };
-
-#ifdef DEBUGGING
- dbf = bb_xfopen(DEBUGTERM, "w");
-
- {
- int i;
-
- for (i = 1; i < argc; i++) {
- debug(argv[i]);
- debug("\n");
- }
- }
-#endif
-
- /* Parse command-line arguments. */
-
- parse_args(argc, argv, &options);
-
-#ifdef __linux__
- setsid();
-#endif
-
- /* Update the utmp file. */
-
-
-#ifdef SYSV_STYLE
-#ifdef CONFIG_FEATURE_UTMP
- update_utmp(options.tty);
-#endif
-#endif
-
- debug("calling open_tty\n");
- /* Open the tty as standard { input, output, error }. */
- open_tty(options.tty, &termio, options.flags & F_LOCAL);
-
-#ifdef __linux__
- {
- int iv;
-
- iv = getpid();
- ioctl(0, TIOCSPGRP, &iv);
- }
-#endif
- /* Initialize the termio settings (raw mode, eight-bit, blocking i/o). */
- debug("calling termio_init\n");
- termio_init(&termio, options.speeds[FIRST_SPEED], &options);
-
- /* write the modem init string and DON'T flush the buffers */
- if (options.flags & F_INITSTRING) {
- debug("writing init string\n");
- write(1, options.initstring, strlen(options.initstring));
- }
-
- if (!(options.flags & F_LOCAL)) {
- /* go to blocking write mode unless -L is specified */
- fcntl(1, F_SETFL, fcntl(1, F_GETFL, 0) & ~O_NONBLOCK);
- }
-
- /* Optionally detect the baud rate from the modem status message. */
- debug("before autobaud\n");
- if (options.flags & F_PARSE)
- auto_baud(&termio);