Changeset 5924 in /cluster/svnroot


Ignore:
Timestamp:
Mar 19, 2017 6:54:02 PM (4 years ago)
Author:
skylar
Message:

only use chvt if not using a TTY re #988

File:
1 edited

Legend:

Unmodified
Added
Removed
  • bccd-ng/branches/skylar/bccd-3.4.0-build_ng/src/bin/bccd-passwd-wrapper

    r5879 r5924  
    2828use Bccd;
    2929use POSIX;
     30use UI::Dialog;
     31
     32# Return true if both STDIN and STDOUT are connected to a TTY, else undef
     33sub test_tty() {
     34    if(-t STDIN && -t STDOUT) {
     35        return 1;
     36    }
     37    return;
     38}
    3039
    3140if(!defined($ARGV[0])) {
     
    3342}
    3443
    35 my($Bccd,$user,$passwd,$CHVT);
     44my($Bccd,$user,$passwd,$CHVT,$am_tty);
    3645
    37 # Change terminal to tty2
    38 open($CHVT, '|-', '/bin/chvt', '2',)
    39     or die "Can't run chvt: $!\n";
    40 close($CHVT);
     46# Change terminal to tty2 if no TTY is setup (i.e. during boot process)
     47if(!defined(test_tty())) {
     48    open($CHVT, '|-', '/bin/chvt', '2',)
     49        or die "Can't run chvt: $!\n";
     50    close($CHVT);
     51}
     52else {
     53    $am_tty = 1;
     54}
    4155
    4256$Bccd = new Bccd();
     
    6680
    6781# Change terminal back to tty1 to avoid hang (#988)
    68 open($CHVT, '|-', '/bin/chvt', '1',)
    69     or die "Can't run chvt: $!\n";
    70 close($CHVT);
     82if(!defined($am_tty)) {
     83    open($CHVT, '|-', '/bin/chvt', '1',)
     84        or die "Can't run chvt: $!\n";
     85    close($CHVT);
     86}
Note: See TracChangeset for help on using the changeset viewer.