Ignore:
Timestamp:
Nov 4, 2007, 3:16:40 AM (17 years ago)
Author:
Bruno Cornec
Message:

Update to busybox 1.7.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.5/mindi-busybox/console-tools/openvt.c

    r821 r1765  
    1111/* getopt not needed */
    1212
    13 #include <stdio.h>
    14 #include <stdlib.h>
    15 #include <unistd.h>
    16 #include <fcntl.h>
    17 #include <string.h>
    18 #include <sys/types.h>
    19 #include <ctype.h>
     13#include "libbb.h"
    2014
    21 #include "busybox.h"
    22 
     15int openvt_main(int argc, char **argv);
    2316int openvt_main(int argc, char **argv)
    2417{
    25     int fd;
    2618    char vtname[sizeof(VC_FORMAT) + 2];
    2719
     20    if (argc < 3)
     21        bb_show_usage();
    2822
    29     if (argc < 3) {
    30         bb_show_usage();
    31     }
    32     /* check for Illegal vt number: < 1 or > 12 */
    33     sprintf(vtname, VC_FORMAT, (int)bb_xgetlarg(argv[1], 10, 1, 12));
     23    /* check for illegal vt number: < 1 or > 63 */
     24    sprintf(vtname, VC_FORMAT, (int)xatou_range(argv[1], 1, 63));
    3425
    35     if (fork() == 0) {
    36         /* leave current vt */
    37         if (setsid() < 0) {
    38             bb_perror_msg_and_die("setsid");
    39         }
    40         close(0);           /* so that new vt becomes stdin */
     26    bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS, argv);
     27    /* grab new one */
     28    close(0);
     29    xopen(vtname, O_RDWR);
     30    dup2(0, STDOUT_FILENO);
     31    dup2(0, STDERR_FILENO);
    4132
    42         /* and grab new one */
    43         fd = bb_xopen(vtname, O_RDWR);
    44 
    45         /* Reassign stdout and sterr */
    46         dup2(fd, STDOUT_FILENO);
    47         dup2(fd, STDERR_FILENO);
    48 
    49         execvp(argv[2], &argv[2]);
    50         _exit(1);
    51     }
    52     return EXIT_SUCCESS;
     33    BB_EXECVP(argv[2], &argv[2]);
     34    _exit(1);
    5335}
Note: See TracChangeset for help on using the changeset viewer.