1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*--------------------------------*-C-*---------------------------------* |
2 | * File: init.c |
2 | * File: init.c |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * $Id: init.C,v 1.6 2003/11/25 17:11:33 pcg Exp $ |
4 | * $Id: init.C,v 1.8 2003/11/27 10:12:10 pcg Exp $ |
5 | * |
5 | * |
6 | * All portions of code are copyright by their respective author/s. |
6 | * All portions of code are copyright by their respective author/s. |
7 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
7 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
8 | * - original version |
8 | * - original version |
9 | * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> |
9 | * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> |
… | |
… | |
473 | } else if (i > STDIN_FILENO) { |
473 | } else if (i > STDIN_FILENO) { |
474 | dup2(i, STDIN_FILENO); |
474 | dup2(i, STDIN_FILENO); |
475 | close(i); |
475 | close(i); |
476 | } |
476 | } |
477 | dup2(STDERR_FILENO, STDOUT_FILENO); |
477 | dup2(STDERR_FILENO, STDOUT_FILENO); |
|
|
478 | #if 0 // schmorp sayz closing filies is murder |
478 | for (i = STDERR_FILENO + 1; i < R->num_fds; i++) { |
479 | for (i = STDERR_FILENO + 1; i < R->num_fds; i++) { |
479 | #ifdef __sgi /* Alex Coventry says we need 4 & 7 too */ |
480 | #ifdef __sgi /* Alex Coventry says we need 4 & 7 too */ |
480 | if (i == 4 || i == 7) |
481 | if (i == 4 || i == 7) |
481 | continue; |
482 | continue; |
482 | #endif |
483 | #endif |
483 | close(i); |
484 | close(i); |
484 | } |
485 | } |
|
|
486 | #endif |
485 | } |
487 | } |
486 | |
488 | |
487 | /*----------------------------------------------------------------------*/ |
489 | /*----------------------------------------------------------------------*/ |
488 | /* EXTPROTO */ |
490 | /* EXTPROTO */ |
489 | const char ** |
491 | const char ** |
… | |
… | |
1299 | else if (STRCMP(R->key_backspace, "DEC") == 0) |
1301 | else if (STRCMP(R->key_backspace, "DEC") == 0) |
1300 | er = '\177'; /* the initial state anyway */ |
1302 | er = '\177'; /* the initial state anyway */ |
1301 | else |
1303 | else |
1302 | #endif |
1304 | #endif |
1303 | er = -1; |
1305 | er = -1; |
|
|
1306 | |
1304 | rxvt_get_ttymode(&(R->tio), er); |
1307 | rxvt_get_ttymode(&(R->tio), er); |
1305 | |
|
|
1306 | /* install exit handler for cleanup */ |
|
|
1307 | #ifdef HAVE_ATEXIT |
|
|
1308 | atexit(rxvt_clean_exit); |
|
|
1309 | #else |
|
|
1310 | # ifdef HAVE_ON_EXIT |
|
|
1311 | on_exit(rxvt_clean_exit, NULL); /* non-ANSI exit handler */ |
|
|
1312 | # endif |
|
|
1313 | #endif |
|
|
1314 | |
|
|
1315 | signal(SIGHUP, rxvt_Exit_signal); |
|
|
1316 | #ifndef __svr4__ |
|
|
1317 | signal(SIGINT, rxvt_Exit_signal); |
|
|
1318 | #endif |
|
|
1319 | signal(SIGQUIT, rxvt_Exit_signal); |
|
|
1320 | signal(SIGTERM, rxvt_Exit_signal); |
|
|
1321 | signal(SIGCHLD, rxvt_Child_signal); |
|
|
1322 | |
|
|
1323 | /* need to trap SIGURG for SVR4 (Unixware) rlogin */ |
|
|
1324 | /* signal (SIGURG, SIG_DFL); */ |
|
|
1325 | |
1308 | |
1326 | #ifndef __QNX__ |
1309 | #ifndef __QNX__ |
1327 | /* spin off the command interpreter */ |
1310 | /* spin off the command interpreter */ |
1328 | switch (R->cmd_pid = fork()) { |
1311 | switch (R->cmd_pid = fork()) { |
1329 | case -1: |
1312 | case -1: |
… | |
… | |
1413 | } |
1396 | } |
1414 | #endif /* SRIOCSREDIR */ |
1397 | #endif /* SRIOCSREDIR */ |
1415 | } |
1398 | } |
1416 | |
1399 | |
1417 | /* reset signals and spin off the command interpreter */ |
1400 | /* reset signals and spin off the command interpreter */ |
1418 | signal(SIGINT, SIG_DFL); |
1401 | signal (SIGINT, SIG_DFL); |
1419 | signal(SIGQUIT, SIG_DFL); |
1402 | signal (SIGQUIT, SIG_DFL); |
1420 | signal(SIGCHLD, SIG_DFL); |
1403 | signal (SIGCHLD, SIG_DFL); |
1421 | /* |
1404 | /* |
1422 | * mimick login's behavior by disabling the job control signals |
1405 | * mimick login's behavior by disabling the job control signals |
1423 | * a shell that wants them can turn them back on |
1406 | * a shell that wants them can turn them back on |
1424 | */ |
1407 | */ |
1425 | #ifdef SIGTSTP |
1408 | #ifdef SIGTSTP |
1426 | signal(SIGTSTP, SIG_IGN); |
1409 | signal (SIGTSTP, SIG_IGN); |
1427 | signal(SIGTTIN, SIG_IGN); |
1410 | signal (SIGTTIN, SIG_IGN); |
1428 | signal(SIGTTOU, SIG_IGN); |
1411 | signal (SIGTTOU, SIG_IGN); |
1429 | #endif /* SIGTSTP */ |
1412 | #endif /* SIGTSTP */ |
1430 | |
1413 | |
1431 | /* set window size */ |
1414 | /* set window size */ |
1432 | rxvt_tt_winsize(STDIN_FILENO, R->TermWin.ncol, R->TermWin.nrow, 0); |
1415 | rxvt_tt_winsize(STDIN_FILENO, R->TermWin.ncol, R->TermWin.nrow, 0); |
1433 | |
1416 | |