… | |
… | |
494 | cmd_argv[i] = (const char *)argv[i + r_argc + 1]; |
494 | cmd_argv[i] = (const char *)argv[i + r_argc + 1]; |
495 | |
495 | |
496 | cmd_argv[i] = NULL; |
496 | cmd_argv[i] = NULL; |
497 | } |
497 | } |
498 | |
498 | |
499 | /* clear all resources */ |
|
|
500 | for (i = 0; i < NUM_RESOURCES;) |
|
|
501 | rs[i++] = NULL; |
|
|
502 | |
|
|
503 | rs[Rs_name] = rxvt_r_basename (argv[0]); |
499 | rs[Rs_name] = rxvt_r_basename (argv[0]); |
504 | |
500 | |
505 | /* |
501 | /* |
506 | * Open display, get options/resources and create the window |
502 | * Open display, get options/resources and create the window |
507 | */ |
503 | */ |
… | |
… | |
522 | } |
518 | } |
523 | #endif |
519 | #endif |
524 | |
520 | |
525 | if (!display |
521 | if (!display |
526 | && ! (display = displays.get (rs[Rs_display_name]))) |
522 | && ! (display = displays.get (rs[Rs_display_name]))) |
527 | { |
|
|
528 | rxvt_print_error ("can't open display %s", rs[Rs_display_name]); |
523 | rxvt_fatal ("can't open display %s", rs[Rs_display_name]); |
529 | exit (EXIT_FAILURE); |
|
|
530 | } |
|
|
531 | |
524 | |
532 | extract_resources (display->display, rs[Rs_name]); |
525 | extract_resources (display->display, rs[Rs_name]); |
533 | |
526 | |
534 | /* |
527 | /* |
535 | * set any defaults not already set |
528 | * set any defaults not already set |
… | |
… | |
759 | free (this->locale); |
752 | free (this->locale); |
760 | this->locale = rxvt_strdup (setlocale (LC_CTYPE, locale)); |
753 | this->locale = rxvt_strdup (setlocale (LC_CTYPE, locale)); |
761 | SET_LOCALE (this->locale); |
754 | SET_LOCALE (this->locale); |
762 | mbstate.reset (); |
755 | mbstate.reset (); |
763 | #endif |
756 | #endif |
|
|
757 | #if 0 |
764 | #if HAVE_NL_LANGINFO |
758 | #if HAVE_NL_LANGINFO |
765 | free (codeset); |
759 | free (codeset); |
766 | codeset = strdup (nl_langinfo (CODESET)); |
760 | codeset = strdup (nl_langinfo (CODESET)); |
767 | enc_utf8 = !STRCASECMP (codeset, "UTF-8") |
761 | enc_utf8 = !STRCASECMP (codeset, "UTF-8") |
768 | || !STRCASECMP (codeset, "UTF8"); |
762 | || !STRCASECMP (codeset, "UTF8"); |
769 | #else |
763 | #else |
770 | enc_utf8 = 1; |
764 | enc_utf8 = 1; |
771 | #endif |
765 | #endif |
|
|
766 | #endif |
772 | } |
767 | } |
773 | |
768 | |
774 | void |
769 | void |
775 | rxvt_term::init_xlocale () |
770 | rxvt_term::init_xlocale () |
776 | { |
771 | { |
777 | #ifdef USE_XIM |
772 | #ifdef USE_XIM |
778 | if (!locale) |
773 | if (!locale) |
779 | rxvt_print_error ("Setting locale failed."); |
774 | rxvt_warn ("setting locale failed, working without locale support.\n"); |
780 | else |
775 | else |
781 | { |
776 | { |
782 | Atom wmlocale; |
777 | Atom wmlocale; |
783 | |
778 | |
784 | wmlocale = XInternAtom (display->display, "WM_LOCALE_NAME", False); |
779 | wmlocale = XInternAtom (display->display, "WM_LOCALE_NAME", False); |
… | |
… | |
786 | XA_STRING, 8, PropModeReplace, |
781 | XA_STRING, 8, PropModeReplace, |
787 | (unsigned char *)locale, STRLEN (locale)); |
782 | (unsigned char *)locale, STRLEN (locale)); |
788 | |
783 | |
789 | if (!XSupportsLocale ()) |
784 | if (!XSupportsLocale ()) |
790 | { |
785 | { |
791 | rxvt_print_error ("The locale is not supported by Xlib"); |
786 | rxvt_warn ("the locale is not supported by Xlib, working withotu locale support.\n"); |
792 | return; |
787 | return; |
793 | } |
788 | } |
794 | |
789 | |
795 | im_ev.start (display); |
790 | im_ev.start (display); |
796 | |
791 | |
… | |
… | |
856 | if (Options & Opt_cursorBlink) |
851 | if (Options & Opt_cursorBlink) |
857 | (void)gettimeofday (&lastcursorchange, NULL); |
852 | (void)gettimeofday (&lastcursorchange, NULL); |
858 | #endif |
853 | #endif |
859 | |
854 | |
860 | if ((cmd_fd = run_command (argv)) < 0) |
855 | if ((cmd_fd = run_command (argv)) < 0) |
861 | { |
856 | rxvt_fatal ("failure while running command, aborting"); |
862 | rxvt_print_error ("aborting"); |
|
|
863 | exit (EXIT_FAILURE); |
|
|
864 | } |
|
|
865 | } |
857 | } |
866 | |
858 | |
867 | /*----------------------------------------------------------------------*/ |
859 | /*----------------------------------------------------------------------*/ |
868 | void |
860 | void |
869 | rxvt_term::Get_Colours () |
861 | rxvt_term::Get_Colours () |
… | |
… | |
894 | switch (i) |
886 | switch (i) |
895 | { |
887 | { |
896 | case Color_fg: |
888 | case Color_fg: |
897 | case Color_bg: |
889 | case Color_bg: |
898 | /* fatal: need bg/fg color */ |
890 | /* fatal: need bg/fg color */ |
899 | rxvt_print_error ("aborting"); |
891 | rxvt_fatal ("unable to get foreground/background colour, aborting"); |
900 | exit (EXIT_FAILURE); |
|
|
901 | /* NOTREACHED */ |
892 | /* NOTREACHED */ |
902 | break; |
893 | break; |
903 | #ifndef NO_CURSORCOLOR |
894 | #ifndef NO_CURSORCOLOR |
904 | case Color_cursor2: |
895 | case Color_cursor2: |
905 | xcol = PixColors[Color_fg]; |
896 | xcol = PixColors[Color_fg]; |
… | |
… | |
1249 | /* graphics context for the vt window */ |
1240 | /* graphics context for the vt window */ |
1250 | gcvalue.foreground = PixColors[Color_fg]; |
1241 | gcvalue.foreground = PixColors[Color_fg]; |
1251 | gcvalue.background = PixColors[Color_bg]; |
1242 | gcvalue.background = PixColors[Color_bg]; |
1252 | gcvalue.graphics_exposures = 1; |
1243 | gcvalue.graphics_exposures = 1; |
1253 | TermWin.gc = XCreateGC (display->display, TermWin.vt, |
1244 | TermWin.gc = XCreateGC (display->display, TermWin.vt, |
1254 | GCForeground | GCBackground |
1245 | GCForeground | GCBackground | GCGraphicsExposures, |
1255 | | GCGraphicsExposures, &gcvalue); |
1246 | &gcvalue); |
1256 | |
1247 | |
1257 | TermWin.drawable = new rxvt_drawable (display, TermWin.vt); |
1248 | TermWin.drawable = new rxvt_drawable (display, TermWin.vt); |
1258 | |
1249 | |
1259 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
1250 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
1260 | gcvalue.foreground = PixColors[Color_topShadow]; |
1251 | gcvalue.foreground = PixColors[Color_topShadow]; |
… | |
… | |
1277 | { |
1268 | { |
1278 | int cfd, er; |
1269 | int cfd, er; |
1279 | |
1270 | |
1280 | /* get master (pty) */ |
1271 | /* get master (pty) */ |
1281 | if ((cfd = rxvt_get_pty (& (tty_fd), & (ttydev))) < 0) |
1272 | if ((cfd = rxvt_get_pty (& (tty_fd), & (ttydev))) < 0) |
1282 | { |
|
|
1283 | rxvt_print_error ("can't open pseudo-tty"); |
1273 | rxvt_fatal ("can't open pseudo-tty"); |
1284 | return -1; |
|
|
1285 | } |
|
|
1286 | |
1274 | |
1287 | fcntl (cfd, F_SETFL, O_NONBLOCK); |
1275 | fcntl (cfd, F_SETFL, O_NONBLOCK); |
1288 | |
1276 | |
1289 | /* get slave (tty) */ |
1277 | /* get slave (tty) */ |
1290 | if (tty_fd < 0) |
1278 | if (tty_fd < 0) |
… | |
… | |
1294 | #endif |
1282 | #endif |
1295 | |
1283 | |
1296 | if ((tty_fd = rxvt_get_tty (ttydev)) < 0) |
1284 | if ((tty_fd = rxvt_get_tty (ttydev)) < 0) |
1297 | { |
1285 | { |
1298 | close (cfd); |
1286 | close (cfd); |
1299 | rxvt_print_error ("can't open slave tty %s", ttydev); |
1287 | rxvt_fatal ("can't open slave tty %s", ttydev); |
1300 | return -1; |
|
|
1301 | } |
1288 | } |
1302 | } |
1289 | } |
1303 | #ifndef NO_BACKSPACE_KEY |
1290 | #ifndef NO_BACKSPACE_KEY |
1304 | if (key_backspace[0] && !key_backspace[1]) |
1291 | if (key_backspace[0] && !key_backspace[1]) |
1305 | er = key_backspace[0]; |
1292 | er = key_backspace[0]; |
… | |
… | |
1315 | #ifndef __QNX__ |
1302 | #ifndef __QNX__ |
1316 | /* spin off the command interpreter */ |
1303 | /* spin off the command interpreter */ |
1317 | switch (cmd_pid = fork ()) |
1304 | switch (cmd_pid = fork ()) |
1318 | { |
1305 | { |
1319 | case -1: |
1306 | case -1: |
1320 | rxvt_print_error ("can't fork"); |
1307 | rxvt_fatal ("can't fork"); |
1321 | return -1; |
|
|
1322 | case 0: |
1308 | case 0: |
1323 | close (cfd); /* only keep tty_fd and STDERR open */ |
1309 | close (cfd); /* only keep tty_fd and STDERR open */ |
1324 | |
1310 | |
1325 | init_env (); |
1311 | init_env (); |
1326 | |
1312 | |
1327 | if (rxvt_control_tty (tty_fd, ttydev) < 0) |
1313 | if (rxvt_control_tty (tty_fd, ttydev) < 0) |
1328 | rxvt_print_error ("could not obtain control of tty"); |
1314 | fprintf (stderr, "%s: could not obtain control of tty.", RESNAME); |
1329 | else |
1315 | else |
1330 | { |
1316 | { |
1331 | /* Reopen stdin, stdout and stderr over the tty file descriptor */ |
1317 | /* Reopen stdin, stdout and stderr over the tty file descriptor */ |
1332 | dup2 (tty_fd, STDIN_FILENO); |
1318 | dup2 (tty_fd, STDIN_FILENO); |
1333 | dup2 (tty_fd, STDOUT_FILENO); |
1319 | dup2 (tty_fd, STDOUT_FILENO); |
… | |
… | |
1335 | |
1321 | |
1336 | if (tty_fd > 2) |
1322 | if (tty_fd > 2) |
1337 | close (tty_fd); |
1323 | close (tty_fd); |
1338 | |
1324 | |
1339 | run_child (argv); |
1325 | run_child (argv); |
|
|
1326 | fprintf (stderr, "%s: unable to exec child.", RESNAME); |
1340 | } |
1327 | } |
|
|
1328 | |
1341 | exit (EXIT_FAILURE); |
1329 | _exit (EXIT_FAILURE); |
1342 | /* NOTREACHED */ |
1330 | |
1343 | default: |
1331 | default: |
1344 | { |
1332 | { |
1345 | #if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT) |
1333 | #if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT) |
1346 | int fdstdin; |
1334 | int fdstdin; |
1347 | |
1335 | |
… | |
… | |
1356 | #if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT) |
1344 | #if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT) |
1357 | |
1345 | |
1358 | dup2 (fdstdin, STDIN_FILENO); |
1346 | dup2 (fdstdin, STDIN_FILENO); |
1359 | close (fdstdin); |
1347 | close (fdstdin); |
1360 | #endif |
1348 | #endif |
1361 | |
|
|
1362 | } |
1349 | } |
|
|
1350 | |
1363 | close (tty_fd); /* keep STDERR_FILENO, cmd_fd, display->fd () open */ |
1351 | close (tty_fd); /* keep STDERR_FILENO, cmd_fd, display->fd () open */ |
1364 | break; |
1352 | break; |
1365 | } |
1353 | } |
1366 | #else /* __QNX__ uses qnxspawn () */ |
1354 | #else /* __QNX__ uses qnxspawn () */ |
1367 | fchmod (tty_fd, 0622); |
1355 | fchmod (tty_fd, 0622); |