@@ -1556,37 +1556,6 @@ init_subshell (void)
1556
1556
if (mc_global .shell -> type == SHELL_NONE )
1557
1557
return ;
1558
1558
1559
- // Open a pty for talking to the subshell
1560
-
1561
- // FIXME: We may need to open a fresh pty each time on SVR4
1562
-
1563
- #ifdef HAVE_OPENPTY
1564
- if (openpty (& mc_global .tty .subshell_pty , & subshell_pty_slave , NULL , NULL , NULL ))
1565
- {
1566
- fprintf (stderr , "Cannot open master and slave sides of pty: %s\n" ,
1567
- unix_error_string (errno ));
1568
- mc_global .tty .use_subshell = FALSE;
1569
- return ;
1570
- }
1571
- #else
1572
- mc_global .tty .subshell_pty = pty_open_master (pty_name );
1573
- if (mc_global .tty .subshell_pty == -1 )
1574
- {
1575
- fprintf (stderr , "Cannot open master side of pty: %s\r\n" , unix_error_string (errno ));
1576
- mc_global .tty .use_subshell = FALSE;
1577
- return ;
1578
- }
1579
-
1580
- subshell_pty_slave = pty_open_slave (pty_name );
1581
- if (subshell_pty_slave == -1 )
1582
- {
1583
- fprintf (stderr , "Cannot open slave side of pty %s: %s\r\n" , pty_name ,
1584
- unix_error_string (errno ));
1585
- mc_global .tty .use_subshell = FALSE;
1586
- return ;
1587
- }
1588
- #endif
1589
-
1590
1559
// Create a pipe for receiving the subshell's CWD
1591
1560
1592
1561
if (mc_global .shell -> type == SHELL_TCSH )
@@ -1629,6 +1598,41 @@ init_subshell (void)
1629
1598
mc_global .tty .use_subshell = FALSE;
1630
1599
return ;
1631
1600
}
1601
+
1602
+ // Open a pty for talking to the subshell; do this after
1603
+ // acquiring the pipes, so the latter have a higher chance
1604
+ // of getting a number lower than 10 so the "pwd >&%d" in
1605
+ // the mc-injected precmd does not cause a syntax error, a
1606
+ // ten-second sleep at startup, and other problems.
1607
+
1608
+ // FIXME: We may need to open a fresh pty each time on SVR4
1609
+
1610
+ #ifdef HAVE_OPENPTY
1611
+ if (openpty (& mc_global .tty .subshell_pty , & subshell_pty_slave , NULL , NULL , NULL ))
1612
+ {
1613
+ fprintf (stderr , "Cannot open master and slave sides of pty: %s\n" ,
1614
+ unix_error_string (errno ));
1615
+ mc_global .tty .use_subshell = FALSE;
1616
+ return ;
1617
+ }
1618
+ #else
1619
+ mc_global .tty .subshell_pty = pty_open_master (pty_name );
1620
+ if (mc_global .tty .subshell_pty == -1 )
1621
+ {
1622
+ fprintf (stderr , "Cannot open master side of pty: %s\r\n" , unix_error_string (errno ));
1623
+ mc_global .tty .use_subshell = FALSE;
1624
+ return ;
1625
+ }
1626
+
1627
+ subshell_pty_slave = pty_open_slave (pty_name );
1628
+ if (subshell_pty_slave == -1 )
1629
+ {
1630
+ fprintf (stderr , "Cannot open slave side of pty %s: %s\r\n" , pty_name ,
1631
+ unix_error_string (errno ));
1632
+ mc_global .tty .use_subshell = FALSE;
1633
+ return ;
1634
+ }
1635
+ #endif
1632
1636
}
1633
1637
1634
1638
// Fork the subshell
0 commit comments