… | |
… | |
1370 | rxvt_term::run_command (const char *const *argv) |
1370 | rxvt_term::run_command (const char *const *argv) |
1371 | { |
1371 | { |
1372 | #if ENABLE_FRILLS |
1372 | #if ENABLE_FRILLS |
1373 | if (rs[Rs_pty_fd]) |
1373 | if (rs[Rs_pty_fd]) |
1374 | { |
1374 | { |
1375 | pty.pty = atoi (rs[Rs_pty_fd]); |
1375 | pty->pty = atoi (rs[Rs_pty_fd]); |
1376 | |
1376 | |
1377 | if (pty.pty >= 0) |
1377 | if (pty->pty >= 0) |
1378 | { |
1378 | { |
1379 | if (getfd_hook) |
1379 | if (getfd_hook) |
1380 | pty.pty = (*getfd_hook) (pty.pty); |
1380 | pty->pty = (*getfd_hook) (pty->pty); |
1381 | |
1381 | |
1382 | if (pty.pty < 0 || fcntl (pty.pty, F_SETFL, O_NONBLOCK)) |
1382 | if (pty->pty < 0 || fcntl (pty->pty, F_SETFL, O_NONBLOCK)) |
1383 | rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); |
1383 | rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); |
1384 | } |
1384 | } |
1385 | } |
1385 | } |
1386 | else |
1386 | else |
1387 | #endif |
1387 | #endif |
1388 | if (!pty.get ()) |
1388 | if (!pty->get ()) |
1389 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
1389 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
1390 | |
1390 | |
1391 | pty.set_utf8_mode (enc_utf8); |
1391 | pty->set_utf8_mode (enc_utf8); |
1392 | |
1392 | |
1393 | /* set initial window size */ |
1393 | /* set initial window size */ |
1394 | tt_winch (); |
1394 | tt_winch (); |
1395 | |
1395 | |
1396 | int er; |
1396 | int er; |
… | |
… | |
1420 | rxvt_fatal ("can't fork, aborting.\n"); |
1420 | rxvt_fatal ("can't fork, aborting.\n"); |
1421 | } |
1421 | } |
1422 | case 0: |
1422 | case 0: |
1423 | init_env (); |
1423 | init_env (); |
1424 | |
1424 | |
1425 | if (!pty.make_controlling_tty ()) |
1425 | if (!pty->make_controlling_tty ()) |
1426 | fprintf (stderr, "%s: could not obtain control of tty.", RESNAME); |
1426 | fprintf (stderr, "%s: could not obtain control of tty.", RESNAME); |
1427 | else |
1427 | else |
1428 | { |
1428 | { |
1429 | /* Reopen stdin, stdout and stderr over the tty file descriptor */ |
1429 | /* Reopen stdin, stdout and stderr over the tty file descriptor */ |
1430 | dup2 (pty.tty, STDIN_FILENO); |
1430 | dup2 (pty->tty, STDIN_FILENO); |
1431 | dup2 (pty.tty, STDOUT_FILENO); |
1431 | dup2 (pty->tty, STDOUT_FILENO); |
1432 | dup2 (pty.tty, STDERR_FILENO); |
1432 | dup2 (pty->tty, STDERR_FILENO); |
1433 | |
1433 | |
1434 | // close all our file handles that we do no longer need |
1434 | // close all our file handles that we do no longer need |
1435 | for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++) |
1435 | for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++) |
1436 | { |
1436 | { |
1437 | if ((*t)->pty.pty > 2) close ((*t)->pty.pty); |
1437 | if ((*t)->pty->pty > 2) close ((*t)->pty->pty); |
1438 | if ((*t)->pty.tty > 2) close ((*t)->pty.tty); |
1438 | if ((*t)->pty->tty > 2) close ((*t)->pty->tty); |
1439 | } |
1439 | } |
1440 | |
1440 | |
1441 | run_child (argv); |
1441 | run_child (argv); |
1442 | fprintf (stderr, "%s: unable to exec child.", RESNAME); |
1442 | fprintf (stderr, "%s: unable to exec child.", RESNAME); |
1443 | } |
1443 | } |
… | |
… | |
1448 | { |
1448 | { |
1449 | #if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT) |
1449 | #if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT) |
1450 | int fdstdin; |
1450 | int fdstdin; |
1451 | |
1451 | |
1452 | fdstdin = dup (STDIN_FILENO); |
1452 | fdstdin = dup (STDIN_FILENO); |
1453 | dup2 (pty.tty, STDIN_FILENO); |
1453 | dup2 (pty->tty, STDIN_FILENO); |
1454 | #endif |
1454 | #endif |
1455 | |
1455 | |
1456 | #ifdef UTMP_SUPPORT |
1456 | #ifdef UTMP_SUPPORT |
1457 | privileged_utmp (SAVE); |
1457 | privileged_utmp (SAVE); |
1458 | #endif |
1458 | #endif |
… | |
… | |
1462 | dup2 (fdstdin, STDIN_FILENO); |
1462 | dup2 (fdstdin, STDIN_FILENO); |
1463 | close (fdstdin); |
1463 | close (fdstdin); |
1464 | #endif |
1464 | #endif |
1465 | } |
1465 | } |
1466 | |
1466 | |
1467 | pty.close_tty (); /* keep STDERR_FILENO, pty.pty, display->fd () open */ |
1467 | pty->close_tty (); |
1468 | break; |
1468 | break; |
1469 | } |
1469 | } |
1470 | } |
1470 | } |
1471 | |
1471 | |
1472 | /* ------------------------------------------------------------------------- * |
1472 | /* ------------------------------------------------------------------------- * |