ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/init.C
(Generate patch)

Comparing rxvt-unicode/src/init.C (file contents):
Revision 1.143 by root, Mon Jan 16 15:00:20 2006 UTC vs.
Revision 1.148 by root, Wed Jan 18 19:43:51 2006 UTC

928 { 928 {
929 XGetWindowAttributes (disp, RootWindow (disp, display->screen), &gattr); 929 XGetWindowAttributes (disp, RootWindow (disp, display->screen), &gattr);
930 display->depth = gattr.depth; // doh //TODO, per-term not per-display? 930 display->depth = gattr.depth; // doh //TODO, per-term not per-display?
931 } 931 }
932 932
933 /* grab colors before netscape does */
934 Get_Colours ();
935
936 if (!set_fonts ())
937 rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n");
938
939 parent = DefaultRootWindow (disp);
940
941 attributes.override_redirect = !!OPTION (Opt_override_redirect);
942
933#if ENABLE_FRILLS 943#if ENABLE_FRILLS
934 if (OPTION (Opt_borderLess)) 944 if (OPTION (Opt_borderLess))
935 { 945 {
936 prop = XInternAtom(disp, "_MOTIF_WM_INFO", True); 946 prop = XInternAtom (disp, "_MOTIF_WM_INFO", True);
937 947
938 if (prop == None) 948 if (prop == None)
939 { 949 {
940 /* print_warning("Window Manager does not support MWM hints. Bypassing window manager control for borderless window.\n");*/ 950 /* print_warning("Window Manager does not support MWM hints. Bypassing window manager control for borderless window.\n");*/
941#ifdef PREFER_24BIT
942 attributes.override_redirect = TRUE; 951 attributes.override_redirect = TRUE;
943#endif
944 mwmhints.flags = 0; 952 mwmhints.flags = 0;
945 } 953 }
946 else 954 else
947 { 955 {
948 mwmhints.flags = MWM_HINTS_DECORATIONS; 956 mwmhints.flags = MWM_HINTS_DECORATIONS;
951 } 959 }
952 else 960 else
953 mwmhints.flags = 0; 961 mwmhints.flags = 0;
954#endif 962#endif
955 963
956 /* grab colors before netscape does */
957 Get_Colours ();
958
959 if (!set_fonts ())
960 rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n");
961
962 parent = DefaultRootWindow (disp);
963
964#if ENABLE_XEMBED 964#if ENABLE_XEMBED
965 if (rs[Rs_embed]) 965 if (rs[Rs_embed])
966 { 966 {
967 XWindowAttributes wattr; 967 XWindowAttributes wattr;
968 968
976#endif 976#endif
977 977
978 window_calc (0, 0); 978 window_calc (0, 0);
979 979
980 /* sub-window placement & size in rxvt_resize_subwindows () */ 980 /* sub-window placement & size in rxvt_resize_subwindows () */
981#ifdef PREFER_24BIT
982 attributes.background_pixel = pix_colors_focused[Color_border]; 981 attributes.background_pixel = pix_colors_focused[Color_border];
983 attributes.border_pixel = pix_colors_focused[Color_border]; 982 attributes.border_pixel = pix_colors_focused[Color_border];
984 attributes.colormap = display->cmap; 983 attributes.colormap = display->cmap;
985 top = XCreateWindow (disp, parent, 984 top = XCreateWindow (disp, parent,
986 szHint.x, szHint.y, 985 szHint.x, szHint.y,
987 szHint.width, szHint.height, 986 szHint.width, szHint.height,
988 ext_bwidth, 987 ext_bwidth,
989 display->depth, InputOutput, 988 display->depth, InputOutput,
990 display->visual, 989 display->visual,
991 CWColormap | CWBackPixel | CWBorderPixel, &attributes); 990 CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect,
992#else 991 &attributes);
993 top = XCreateSimpleWindow (disp, parent,
994 szHint.x, szHint.y,
995 szHint.width, szHint.height,
996 ext_bwidth,
997 pix_colors_focused[Color_border],
998 pix_colors_focused[Color_border]);
999#endif
1000 992
1001 this->parent[0] = top; 993 this->parent[0] = top;
1002 994
1003 old_width = szHint.width; 995 old_width = szHint.width;
1004 old_height = szHint.height; 996 old_height = szHint.height;
1370rxvt_term::run_command (const char *const *argv) 1362rxvt_term::run_command (const char *const *argv)
1371{ 1363{
1372#if ENABLE_FRILLS 1364#if ENABLE_FRILLS
1373 if (rs[Rs_pty_fd]) 1365 if (rs[Rs_pty_fd])
1374 { 1366 {
1375 pty.pty = atoi (rs[Rs_pty_fd]); 1367 pty->pty = atoi (rs[Rs_pty_fd]);
1376 1368
1377 if (pty.pty >= 0) 1369 if (pty->pty >= 0)
1378 { 1370 {
1379 if (getfd_hook) 1371 if (getfd_hook)
1380 pty.pty = (*getfd_hook) (pty.pty); 1372 pty->pty = (*getfd_hook) (pty->pty);
1381 1373
1382 if (pty.pty < 0 || fcntl (pty.pty, F_SETFL, O_NONBLOCK)) 1374 if (pty->pty < 0 || fcntl (pty->pty, F_SETFL, O_NONBLOCK))
1383 rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); 1375 rxvt_fatal ("unusable pty-fd filehandle, aborting.\n");
1384 } 1376 }
1385 } 1377 }
1386 else 1378 else
1387#endif 1379#endif
1388 if (!pty.get ()) 1380 if (!pty->get ())
1389 rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); 1381 rxvt_fatal ("can't initialize pseudo-tty, aborting.\n");
1390 1382
1391 pty.set_utf8_mode (enc_utf8); 1383 pty->set_utf8_mode (enc_utf8);
1392 1384
1393 /* set initial window size */ 1385 /* set initial window size */
1394 tt_winch (); 1386 tt_winch ();
1395 1387
1396 int er; 1388 int er;
1409#if ENABLE_FRILLS 1401#if ENABLE_FRILLS
1410 if (rs[Rs_pty_fd]) 1402 if (rs[Rs_pty_fd])
1411 return; 1403 return;
1412#endif 1404#endif
1413 1405
1414#ifndef __QNX__
1415 /* spin off the command interpreter */ 1406 /* spin off the command interpreter */
1416 switch (cmd_pid = fork ()) 1407 switch (cmd_pid = fork ())
1417 { 1408 {
1418 case -1: 1409 case -1:
1419 { 1410 {
1421 rxvt_fatal ("can't fork, aborting.\n"); 1412 rxvt_fatal ("can't fork, aborting.\n");
1422 } 1413 }
1423 case 0: 1414 case 0:
1424 init_env (); 1415 init_env ();
1425 1416
1426 if (!pty.make_controlling_tty ()) 1417 if (!pty->make_controlling_tty ())
1427 fprintf (stderr, "%s: could not obtain control of tty.", RESNAME); 1418 fprintf (stderr, "%s: could not obtain control of tty.", RESNAME);
1428 else 1419 else
1429 { 1420 {
1430 /* Reopen stdin, stdout and stderr over the tty file descriptor */ 1421 /* Reopen stdin, stdout and stderr over the tty file descriptor */
1431 dup2 (pty.tty, STDIN_FILENO); 1422 dup2 (pty->tty, STDIN_FILENO);
1432 dup2 (pty.tty, STDOUT_FILENO); 1423 dup2 (pty->tty, STDOUT_FILENO);
1433 dup2 (pty.tty, STDERR_FILENO); 1424 dup2 (pty->tty, STDERR_FILENO);
1434 1425
1435 // close all our file handles that we do no longer need 1426 // close all our file handles that we do no longer need
1436 for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++) 1427 for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++)
1437 { 1428 {
1438 if ((*t)->pty.pty > 2) close ((*t)->pty.pty); 1429 if ((*t)->pty->pty > 2) close ((*t)->pty->pty);
1439 if ((*t)->pty.tty > 2) close ((*t)->pty.tty); 1430 if ((*t)->pty->tty > 2) close ((*t)->pty->tty);
1440 } 1431 }
1441 1432
1442 run_child (argv); 1433 run_child (argv);
1443 fprintf (stderr, "%s: unable to exec child.", RESNAME); 1434 fprintf (stderr, "%s: unable to exec child.", RESNAME);
1444 } 1435 }
1445 1436
1446 _exit (EXIT_FAILURE); 1437 _exit (EXIT_FAILURE);
1447 1438
1448 default: 1439 default:
1449 {
1450#if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT)
1451 int fdstdin;
1452
1453 fdstdin = dup (STDIN_FILENO);
1454 dup2 (pty.tty, STDIN_FILENO);
1455#endif
1456
1457#ifdef UTMP_SUPPORT 1440#if UTMP_SUPPORT
1458 privileged_utmp (SAVE); 1441 if (!OPTION (Opt_utmpInhibit))
1442 pty->login (cmd_pid, OPTION (Opt_loginShell), rs[Rs_display_name]);
1459#endif 1443#endif
1460 1444
1461#if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT) 1445 pty->close_tty ();
1462
1463 dup2 (fdstdin, STDIN_FILENO);
1464 close (fdstdin);
1465#endif
1466 }
1467
1468 pty.close_tty (); /* keep STDERR_FILENO, pty.pty, display->fd () open */
1469 break; 1446 break;
1470 } 1447 }
1471#else /* __QNX__ uses qnxspawn () */
1472 fchmod (pty.tty, 0622);
1473 fcntl (pty.tty, F_SETFD, FD_CLOEXEC);
1474 fcntl (pty.pty, F_SETFD, FD_CLOEXEC);
1475
1476 if (run_child (argv) == -1)
1477 exit (EXIT_FAILURE);
1478#endif
1479} 1448}
1480 1449
1481/* ------------------------------------------------------------------------- * 1450/* ------------------------------------------------------------------------- *
1482 * CHILD PROCESS OPERATIONS * 1451 * CHILD PROCESS OPERATIONS *
1483 * ------------------------------------------------------------------------- */ 1452 * ------------------------------------------------------------------------- */
1527 // unblock signals (signals are blocked by iom.C 1496 // unblock signals (signals are blocked by iom.C
1528 sigset_t ss; 1497 sigset_t ss;
1529 sigemptyset (&ss); 1498 sigemptyset (&ss);
1530 sigprocmask (SIG_SETMASK, &ss, 0); 1499 sigprocmask (SIG_SETMASK, &ss, 0);
1531 1500
1532#ifndef __QNX__
1533 /* command interpreter path */ 1501 /* command interpreter path */
1534 if (argv != NULL) 1502 if (argv != NULL)
1535 { 1503 {
1536# ifdef DEBUG_CMD 1504# ifdef DEBUG_CMD
1537 int i; 1505 int i;
1563 1531
1564 execlp (shell, argv0, NULL); 1532 execlp (shell, argv0, NULL);
1565 /* no error message: STDERR is closed! */ 1533 /* no error message: STDERR is closed! */
1566 } 1534 }
1567 1535
1568#else /* __QNX__ uses qnxspawn () */
1569
1570 char iov_a[10] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
1571 char *command = NULL, fullcommand[_MAX_PATH];
1572 char **arg_v, *arg_a[2] = { NULL, NULL };
1573
1574 if (argv != NULL)
1575 {
1576 if (access (argv[0], X_OK) == -1)
1577 {
1578 if (strchr (argv[0], '/') == NULL)
1579 {
1580 searchenv (argv[0], "PATH", fullcommand);
1581
1582 if (fullcommand[0] != '\0')
1583 command = fullcommand;
1584 }
1585
1586 if (access (command, X_OK) == -1)
1587 return -1;
1588 }
1589 else
1590 command = argv[0];
1591
1592 arg_v = argv;
1593 }
1594 else
1595 {
1596 if ((command = getenv ("SHELL")) == NULL || *command == '\0')
1597 command = "/bin/sh";
1598
1599 arg_a[0] = my_basename (command);
1600
1601 if (OPTION (Opt_loginShell))
1602 {
1603 login = rxvt_malloc ((strlen (arg_a[0]) + 2) * sizeof (char));
1604
1605 login[0] = '-';
1606 strcpy (&login[1], arg_a[0]);
1607 arg_a[0] = login;
1608 }
1609
1610 arg_v = arg_a;
1611 }
1612
1613 iov_a[0] = iov_a[1] = iov_a[2] = pty.tty;
1614 cmd_pid = qnx_spawn (0, 0, 0, -1, -1,
1615 _SPAWN_SETSID | _SPAWN_TCSETPGRP,
1616 command, arg_v, environ, iov_a, 0);
1617 if (login)
1618 free (login);
1619
1620 pty.close_tty ();
1621 return pty.pty;
1622#endif
1623
1624 return -1; 1536 return -1;
1625} 1537}
1626 1538
1627/*----------------------- end-of-file (C source) -----------------------*/ 1539/*----------------------- end-of-file (C source) -----------------------*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines