… | |
… | |
203 | #endif |
203 | #endif |
204 | #ifdef TRANSPARENT |
204 | #ifdef TRANSPARENT |
205 | "_XROOTPMAP_ID", |
205 | "_XROOTPMAP_ID", |
206 | "ESETROOT_PMAP_ID", |
206 | "ESETROOT_PMAP_ID", |
207 | #endif |
207 | #endif |
208 | #ifdef OFFIX_DND |
|
|
209 | "DndProtocol", |
|
|
210 | "DndSelection", |
|
|
211 | #endif |
|
|
212 | #if ENABLE_XEMBED |
208 | #if ENABLE_XEMBED |
213 | "_XEMBED", |
209 | "_XEMBED", |
214 | "_XEMBED_INFO", |
210 | "_XEMBED_INFO", |
215 | #endif |
211 | #endif |
216 | }; |
212 | }; |
… | |
… | |
256 | bgPixmap.pixmap = None; |
252 | bgPixmap.pixmap = None; |
257 | #endif |
253 | #endif |
258 | |
254 | |
259 | last_bot = last_state = -1; |
255 | last_bot = last_state = -1; |
260 | |
256 | |
261 | #ifdef MENUBAR |
|
|
262 | menu_readonly = 1; |
|
|
263 | # if ! (MENUBAR_MAX > 1) |
|
|
264 | CurrentBar = &BarList; |
|
|
265 | # endif /* (MENUBAR_MAX > 1) */ |
|
|
266 | #endif |
|
|
267 | |
|
|
268 | return true; |
257 | return true; |
269 | } |
258 | } |
270 | |
259 | |
271 | void |
260 | void |
272 | rxvt_term::init_secondary () |
261 | rxvt_term::init_secondary () |
… | |
… | |
339 | rs[Rs_name] = rxvt_r_basename (argv[0]); |
328 | rs[Rs_name] = rxvt_r_basename (argv[0]); |
340 | |
329 | |
341 | /* |
330 | /* |
342 | * Open display, get options/resources and create the window |
331 | * Open display, get options/resources and create the window |
343 | */ |
332 | */ |
344 | { |
|
|
345 | TEMP_ENV; |
|
|
346 | |
333 | |
347 | if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL) |
334 | if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL) |
348 | rs[Rs_display_name] = ":0"; |
335 | rs[Rs_display_name] = ":0"; |
349 | |
336 | |
350 | get_options (r_argc, r_argv); |
337 | get_options (r_argc, r_argv); |
351 | |
338 | |
352 | if (!(display = displays.get (rs[Rs_display_name]))) |
339 | if (!(display = displays.get (rs[Rs_display_name]))) |
353 | rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]); |
340 | rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]); |
354 | |
341 | |
355 | extract_resources (); |
342 | extract_resources (); |
356 | } |
|
|
357 | |
343 | |
358 | free (r_argv); |
344 | free (r_argv); |
359 | |
345 | |
360 | /* |
346 | /* |
361 | * set any defaults not already set |
347 | * set any defaults not already set |
… | |
… | |
581 | * This should support all European type languages. |
567 | * This should support all European type languages. |
582 | */ |
568 | */ |
583 | void |
569 | void |
584 | rxvt_term::set_locale (const char *locale) |
570 | rxvt_term::set_locale (const char *locale) |
585 | { |
571 | { |
586 | TEMP_ENV; |
572 | set_environ (envv); |
587 | |
573 | |
588 | #if HAVE_XSETLOCALE || HAVE_SETLOCALE |
574 | #if HAVE_XSETLOCALE || HAVE_SETLOCALE |
589 | free (this->locale); |
575 | free (this->locale); |
590 | this->locale = setlocale (LC_CTYPE, locale); |
576 | this->locale = setlocale (LC_CTYPE, locale); |
591 | |
577 | |
… | |
… | |
622 | } |
608 | } |
623 | |
609 | |
624 | void |
610 | void |
625 | rxvt_term::init_xlocale () |
611 | rxvt_term::init_xlocale () |
626 | { |
612 | { |
627 | TEMP_ENV; |
613 | set_environ (envv); |
628 | |
614 | |
629 | #ifdef USE_XIM |
615 | #ifdef USE_XIM |
630 | if (!locale) |
616 | if (!locale) |
631 | rxvt_warn ("setting locale failed, working without locale support.\n"); |
617 | rxvt_warn ("setting locale failed, working without locale support.\n"); |
632 | else |
618 | else |
… | |
… | |
673 | if (strcmp (key_backspace, "DEC") == 0) |
659 | if (strcmp (key_backspace, "DEC") == 0) |
674 | priv_modes |= PrivMode_HaveBackSpace; |
660 | priv_modes |= PrivMode_HaveBackSpace; |
675 | #endif |
661 | #endif |
676 | |
662 | |
677 | /* add value for scrollBar */ |
663 | /* add value for scrollBar */ |
678 | if (scrollbar_visible ()) |
664 | if (scrollBar.state) |
679 | { |
665 | { |
680 | priv_modes |= PrivMode_scrollBar; |
666 | priv_modes |= PrivMode_scrollBar; |
681 | SavedModes |= PrivMode_scrollBar; |
667 | SavedModes |= PrivMode_scrollBar; |
682 | } |
|
|
683 | |
|
|
684 | if (menubar_visible ()) |
|
|
685 | { |
|
|
686 | priv_modes |= PrivMode_menuBar; |
|
|
687 | SavedModes |= PrivMode_menuBar; |
|
|
688 | } |
668 | } |
689 | |
669 | |
690 | run_command (argv); |
670 | run_command (argv); |
691 | } |
671 | } |
692 | |
672 | |
… | |
… | |
760 | if (!rs[Rs_color + Color_pointer_bg]) pix_colors[Color_pointer_bg] = pix_colors[Color_bg]; |
740 | if (!rs[Rs_color + Color_pointer_bg]) pix_colors[Color_pointer_bg] = pix_colors[Color_bg]; |
761 | if (!rs[Rs_color + Color_border] ) pix_colors[Color_border] = pix_colors[Color_fg]; |
741 | if (!rs[Rs_color + Color_border] ) pix_colors[Color_border] = pix_colors[Color_fg]; |
762 | } |
742 | } |
763 | |
743 | |
764 | /* |
744 | /* |
765 | * get scrollBar/menuBar shadow colors |
745 | * get scrollBar shadow colors |
766 | * |
746 | * |
767 | * The calculations of topShadow/bottomShadow values are adapted |
747 | * The calculations of topShadow/bottomShadow values are adapted |
768 | * from the fvwm window manager. |
748 | * from the fvwm window manager. |
769 | */ |
749 | */ |
770 | #ifdef KEEP_SCROLLCOLOR |
750 | #ifdef KEEP_SCROLLCOLOR |
… | |
… | |
925 | #if ENABLE_FRILLS |
905 | #if ENABLE_FRILLS |
926 | Atom prop = None; |
906 | Atom prop = None; |
927 | MWMHints mwmhints; |
907 | MWMHints mwmhints; |
928 | #endif |
908 | #endif |
929 | XGCValues gcvalue; |
909 | XGCValues gcvalue; |
930 | long vt_emask; |
|
|
931 | XSetWindowAttributes attributes; |
910 | XSetWindowAttributes attributes; |
932 | XWindowAttributes gattr; |
911 | XWindowAttributes gattr; |
933 | Window top, parent; |
912 | Window top, parent; |
934 | dDisp; |
913 | dDisp; |
935 | |
914 | |
… | |
… | |
945 | { |
924 | { |
946 | XGetWindowAttributes (disp, RootWindow (disp, display->screen), &gattr); |
925 | XGetWindowAttributes (disp, RootWindow (disp, display->screen), &gattr); |
947 | display->depth = gattr.depth; // doh //TODO, per-term not per-display? |
926 | display->depth = gattr.depth; // doh //TODO, per-term not per-display? |
948 | } |
927 | } |
949 | |
928 | |
|
|
929 | /* grab colors before netscape does */ |
|
|
930 | Get_Colours (); |
|
|
931 | |
|
|
932 | if (!set_fonts ()) |
|
|
933 | rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); |
|
|
934 | |
|
|
935 | parent = DefaultRootWindow (disp); |
|
|
936 | |
|
|
937 | attributes.override_redirect = !!OPTION (Opt_override_redirect); |
|
|
938 | |
950 | #if ENABLE_FRILLS |
939 | #if ENABLE_FRILLS |
951 | if (OPTION (Opt_borderLess)) |
940 | if (OPTION (Opt_borderLess)) |
952 | { |
941 | { |
953 | prop = XInternAtom(disp, "_MOTIF_WM_INFO", True); |
942 | prop = XInternAtom (disp, "_MOTIF_WM_INFO", True); |
954 | |
943 | |
955 | if (prop == None) |
944 | if (prop == None) |
956 | { |
945 | { |
957 | /* print_warning("Window Manager does not support MWM hints. Bypassing window manager control for borderless window.\n");*/ |
946 | /* print_warning("Window Manager does not support MWM hints. Bypassing window manager control for borderless window.\n");*/ |
958 | #ifdef PREFER_24BIT |
|
|
959 | attributes.override_redirect = TRUE; |
947 | attributes.override_redirect = TRUE; |
960 | #endif |
|
|
961 | mwmhints.flags = 0; |
948 | mwmhints.flags = 0; |
962 | } |
949 | } |
963 | else |
950 | else |
964 | { |
951 | { |
965 | mwmhints.flags = MWM_HINTS_DECORATIONS; |
952 | mwmhints.flags = MWM_HINTS_DECORATIONS; |
… | |
… | |
968 | } |
955 | } |
969 | else |
956 | else |
970 | mwmhints.flags = 0; |
957 | mwmhints.flags = 0; |
971 | #endif |
958 | #endif |
972 | |
959 | |
973 | /* grab colors before netscape does */ |
|
|
974 | Get_Colours (); |
|
|
975 | |
|
|
976 | if (!set_fonts ()) |
|
|
977 | rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); |
|
|
978 | |
|
|
979 | parent = DefaultRootWindow (disp); |
|
|
980 | |
|
|
981 | #if ENABLE_XEMBED |
960 | #if ENABLE_XEMBED |
982 | if (rs[Rs_embed]) |
961 | if (rs[Rs_embed]) |
983 | { |
962 | { |
984 | XWindowAttributes wattr; |
963 | XWindowAttributes wattr; |
985 | |
964 | |
… | |
… | |
993 | #endif |
972 | #endif |
994 | |
973 | |
995 | window_calc (0, 0); |
974 | window_calc (0, 0); |
996 | |
975 | |
997 | /* sub-window placement & size in rxvt_resize_subwindows () */ |
976 | /* sub-window placement & size in rxvt_resize_subwindows () */ |
998 | #ifdef PREFER_24BIT |
|
|
999 | attributes.background_pixel = pix_colors_focused[Color_border]; |
977 | attributes.background_pixel = pix_colors_focused[Color_border]; |
1000 | attributes.border_pixel = pix_colors_focused[Color_border]; |
978 | attributes.border_pixel = pix_colors_focused[Color_border]; |
1001 | attributes.colormap = display->cmap; |
979 | attributes.colormap = display->cmap; |
1002 | top = XCreateWindow (disp, parent, |
980 | top = XCreateWindow (disp, parent, |
1003 | szHint.x, szHint.y, |
981 | szHint.x, szHint.y, |
1004 | szHint.width, szHint.height, |
982 | szHint.width, szHint.height, |
1005 | ext_bwidth, |
983 | ext_bwidth, |
1006 | display->depth, InputOutput, |
984 | display->depth, InputOutput, |
1007 | display->visual, |
985 | display->visual, |
1008 | CWColormap | CWBackPixel | CWBorderPixel, &attributes); |
986 | CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect, |
1009 | #else |
987 | &attributes); |
1010 | top = XCreateSimpleWindow (disp, parent, |
|
|
1011 | szHint.x, szHint.y, |
|
|
1012 | szHint.width, szHint.height, |
|
|
1013 | ext_bwidth, |
|
|
1014 | pix_colors_focused[Color_border], |
|
|
1015 | pix_colors_focused[Color_border]); |
|
|
1016 | #endif |
|
|
1017 | |
988 | |
1018 | this->parent[0] = top; |
989 | this->parent[0] = top; |
1019 | |
990 | |
1020 | old_width = szHint.width; |
991 | old_width = szHint.width; |
1021 | old_height = szHint.height; |
992 | old_height = szHint.height; |
… | |
… | |
1075 | #endif |
1046 | #endif |
1076 | |
1047 | |
1077 | /* vt cursor: Black-on-White is standard, but this is more popular */ |
1048 | /* vt cursor: Black-on-White is standard, but this is more popular */ |
1078 | TermWin_cursor = XCreateFontCursor (disp, XC_xterm); |
1049 | TermWin_cursor = XCreateFontCursor (disp, XC_xterm); |
1079 | |
1050 | |
1080 | #if defined(HAVE_SCROLLBARS) || defined(MENUBAR) |
1051 | #ifdef HAVE_SCROLLBARS |
1081 | /* cursor (menuBar/scrollBar): Black-on-White */ |
1052 | /* cursor scrollBar: Black-on-White */ |
1082 | leftptr_cursor = XCreateFontCursor (disp, XC_left_ptr); |
1053 | leftptr_cursor = XCreateFontCursor (disp, XC_left_ptr); |
1083 | #endif |
1054 | #endif |
1084 | |
1055 | |
1085 | /* the vt window */ |
1056 | /* the vt window */ |
1086 | vt = XCreateSimpleWindow (disp, top, |
1057 | vt = XCreateSimpleWindow (disp, top, |
… | |
… | |
1098 | attributes.bit_gravity = NorthWestGravity; |
1069 | attributes.bit_gravity = NorthWestGravity; |
1099 | XChangeWindowAttributes (disp, vt, CWBitGravity, &attributes); |
1070 | XChangeWindowAttributes (disp, vt, CWBitGravity, &attributes); |
1100 | |
1071 | |
1101 | vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; |
1072 | vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; |
1102 | |
1073 | |
1103 | if (OPTION (Opt_pointerBlank) |
1074 | if (OPTION (Opt_pointerBlank)) |
1104 | #ifdef ENABLE_PERL |
|
|
1105 | || perl.self |
|
|
1106 | #endif |
|
|
1107 | ) |
|
|
1108 | vt_emask |= PointerMotionMask; |
1075 | vt_emask |= PointerMotionMask; |
1109 | else |
1076 | else |
1110 | vt_emask |= Button1MotionMask | Button3MotionMask; |
1077 | vt_emask |= Button1MotionMask | Button3MotionMask; |
1111 | |
1078 | |
1112 | XSelectInput (disp, vt, vt_emask); |
1079 | vt_select_input (); |
|
|
1080 | |
1113 | vt_ev.start (display, vt); |
1081 | vt_ev.start (display, vt); |
1114 | |
|
|
1115 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
|
|
1116 | if (menuBar_height ()) |
|
|
1117 | { |
|
|
1118 | menuBar.win = XCreateSimpleWindow (disp, top, |
|
|
1119 | window_vt_x, 0, |
|
|
1120 | width, |
|
|
1121 | menuBar_TotalHeight (), |
|
|
1122 | 0, |
|
|
1123 | pix_colors_focused[Color_fg], |
|
|
1124 | pix_colors_focused[Color_scroll]); |
|
|
1125 | |
|
|
1126 | #ifdef DEBUG_X |
|
|
1127 | XStoreName (disp, menuBar.win, "menubar"); |
|
|
1128 | #endif |
|
|
1129 | |
|
|
1130 | menuBar.drawable = new rxvt_drawable (display, menuBar.win); |
|
|
1131 | |
|
|
1132 | XDefineCursor (disp, menuBar.win, |
|
|
1133 | XCreateFontCursor (disp, XC_left_ptr)); |
|
|
1134 | |
|
|
1135 | XSelectInput (disp, menuBar.win, |
|
|
1136 | (ExposureMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask)); |
|
|
1137 | menubar_ev.start (display, menuBar.win); |
|
|
1138 | } |
|
|
1139 | #endif |
|
|
1140 | |
1082 | |
1141 | #ifdef XPM_BACKGROUND |
1083 | #ifdef XPM_BACKGROUND |
1142 | if (rs[Rs_backgroundPixmap] != NULL |
1084 | if (rs[Rs_backgroundPixmap] != NULL |
1143 | && ! OPTION (Opt_transparent)) |
1085 | && ! OPTION (Opt_transparent)) |
1144 | { |
1086 | { |
… | |
… | |
1163 | GCForeground | GCBackground | GCGraphicsExposures, |
1105 | GCForeground | GCBackground | GCGraphicsExposures, |
1164 | &gcvalue); |
1106 | &gcvalue); |
1165 | |
1107 | |
1166 | drawable = new rxvt_drawable (display, vt); |
1108 | drawable = new rxvt_drawable (display, vt); |
1167 | |
1109 | |
1168 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
1110 | #ifdef RXVT_SCROLLBAR |
1169 | gcvalue.foreground = pix_colors[Color_topShadow]; |
1111 | gcvalue.foreground = pix_colors[Color_topShadow]; |
1170 | topShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); |
1112 | topShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); |
1171 | gcvalue.foreground = pix_colors[Color_bottomShadow]; |
1113 | gcvalue.foreground = pix_colors[Color_bottomShadow]; |
1172 | botShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); |
1114 | botShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); |
1173 | gcvalue.foreground = pix_colors[ (display->depth <= 2 ? Color_fg : Color_scroll)]; |
1115 | gcvalue.foreground = pix_colors[ (display->depth <= 2 ? Color_fg : Color_scroll)]; |
… | |
… | |
1413 | * the slave. |
1355 | * the slave. |
1414 | */ |
1356 | */ |
1415 | void |
1357 | void |
1416 | rxvt_term::run_command (const char *const *argv) |
1358 | rxvt_term::run_command (const char *const *argv) |
1417 | { |
1359 | { |
1418 | TEMP_ENV; // not very temporary... |
|
|
1419 | |
|
|
1420 | #if ENABLE_FRILLS |
1360 | #if ENABLE_FRILLS |
1421 | if (rs[Rs_pty_fd]) |
1361 | if (rs[Rs_pty_fd]) |
1422 | { |
1362 | { |
1423 | pty.pty = atoi (rs[Rs_pty_fd]); |
1363 | pty->pty = atoi (rs[Rs_pty_fd]); |
1424 | |
1364 | |
1425 | if (pty.pty >= 0) |
1365 | if (pty->pty >= 0) |
1426 | { |
1366 | { |
1427 | if (getfd_hook) |
1367 | if (getfd_hook) |
1428 | pty.pty = (*getfd_hook) (pty.pty); |
1368 | pty->pty = (*getfd_hook) (pty->pty); |
1429 | |
1369 | |
1430 | if (pty.pty < 0 || fcntl (pty.pty, F_SETFL, O_NONBLOCK)) |
1370 | if (pty->pty < 0 || fcntl (pty->pty, F_SETFL, O_NONBLOCK)) |
1431 | rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); |
1371 | rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); |
1432 | } |
1372 | } |
1433 | } |
1373 | } |
1434 | else |
1374 | else |
1435 | #endif |
1375 | #endif |
1436 | if (!pty.get ()) |
1376 | if (!pty->get ()) |
1437 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
1377 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
1438 | |
1378 | |
1439 | pty.set_utf8_mode (enc_utf8); |
1379 | pty->set_utf8_mode (enc_utf8); |
1440 | |
1380 | |
1441 | /* set initial window size */ |
1381 | /* set initial window size */ |
1442 | tt_winch (); |
1382 | tt_winch (); |
1443 | |
1383 | |
1444 | int er; |
1384 | int er; |
… | |
… | |
1457 | #if ENABLE_FRILLS |
1397 | #if ENABLE_FRILLS |
1458 | if (rs[Rs_pty_fd]) |
1398 | if (rs[Rs_pty_fd]) |
1459 | return; |
1399 | return; |
1460 | #endif |
1400 | #endif |
1461 | |
1401 | |
1462 | #ifndef __QNX__ |
|
|
1463 | /* spin off the command interpreter */ |
1402 | /* spin off the command interpreter */ |
1464 | switch (cmd_pid = fork ()) |
1403 | switch (cmd_pid = fork ()) |
1465 | { |
1404 | { |
1466 | case -1: |
1405 | case -1: |
1467 | { |
1406 | { |
… | |
… | |
1469 | rxvt_fatal ("can't fork, aborting.\n"); |
1408 | rxvt_fatal ("can't fork, aborting.\n"); |
1470 | } |
1409 | } |
1471 | case 0: |
1410 | case 0: |
1472 | init_env (); |
1411 | init_env (); |
1473 | |
1412 | |
1474 | if (!pty.make_controlling_tty ()) |
1413 | if (!pty->make_controlling_tty ()) |
1475 | fprintf (stderr, "%s: could not obtain control of tty.", RESNAME); |
1414 | fprintf (stderr, "%s: could not obtain control of tty.", RESNAME); |
1476 | else |
1415 | else |
1477 | { |
1416 | { |
1478 | /* Reopen stdin, stdout and stderr over the tty file descriptor */ |
1417 | /* Reopen stdin, stdout and stderr over the tty file descriptor */ |
1479 | dup2 (pty.tty, STDIN_FILENO); |
1418 | dup2 (pty->tty, STDIN_FILENO); |
1480 | dup2 (pty.tty, STDOUT_FILENO); |
1419 | dup2 (pty->tty, STDOUT_FILENO); |
1481 | dup2 (pty.tty, STDERR_FILENO); |
1420 | dup2 (pty->tty, STDERR_FILENO); |
1482 | |
1421 | |
1483 | // close all our file handles that we do no longer need |
1422 | // close all our file handles that we do no longer need |
1484 | for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++) |
1423 | for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++) |
1485 | { |
1424 | { |
1486 | if ((*t)->pty.pty > 2) close ((*t)->pty.pty); |
1425 | if ((*t)->pty->pty > 2) close ((*t)->pty->pty); |
1487 | if ((*t)->pty.tty > 2) close ((*t)->pty.tty); |
1426 | if ((*t)->pty->tty > 2) close ((*t)->pty->tty); |
1488 | } |
1427 | } |
1489 | |
1428 | |
1490 | run_child (argv); |
1429 | run_child (argv); |
1491 | fprintf (stderr, "%s: unable to exec child.", RESNAME); |
1430 | fprintf (stderr, "%s: unable to exec child.", RESNAME); |
1492 | } |
1431 | } |
1493 | |
1432 | |
1494 | _exit (EXIT_FAILURE); |
1433 | _exit (EXIT_FAILURE); |
1495 | |
1434 | |
1496 | default: |
1435 | default: |
1497 | { |
|
|
1498 | #if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT) |
|
|
1499 | int fdstdin; |
|
|
1500 | |
|
|
1501 | fdstdin = dup (STDIN_FILENO); |
|
|
1502 | dup2 (pty.tty, STDIN_FILENO); |
|
|
1503 | #endif |
|
|
1504 | |
|
|
1505 | #ifdef UTMP_SUPPORT |
1436 | #if UTMP_SUPPORT |
1506 | privileged_utmp (SAVE); |
1437 | if (!OPTION (Opt_utmpInhibit)) |
|
|
1438 | pty->login (cmd_pid, OPTION (Opt_loginShell), rs[Rs_display_name]); |
1507 | #endif |
1439 | #endif |
1508 | |
1440 | |
1509 | #if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT) |
1441 | pty->close_tty (); |
1510 | |
1442 | |
1511 | dup2 (fdstdin, STDIN_FILENO); |
1443 | child_ev.start (cmd_pid); |
1512 | close (fdstdin); |
|
|
1513 | #endif |
|
|
1514 | } |
|
|
1515 | |
1444 | |
1516 | pty.close_tty (); /* keep STDERR_FILENO, pty.pty, display->fd () open */ |
1445 | HOOK_INVOKE ((this, HOOK_CHILD_START, DT_INT, cmd_pid, DT_END)); |
1517 | break; |
1446 | break; |
1518 | } |
1447 | } |
1519 | #else /* __QNX__ uses qnxspawn () */ |
|
|
1520 | fchmod (pty.tty, 0622); |
|
|
1521 | fcntl (pty.tty, F_SETFD, FD_CLOEXEC); |
|
|
1522 | fcntl (pty.pty, F_SETFD, FD_CLOEXEC); |
|
|
1523 | |
|
|
1524 | if (run_child (argv) == -1) |
|
|
1525 | exit (EXIT_FAILURE); |
|
|
1526 | #endif |
|
|
1527 | } |
1448 | } |
1528 | |
1449 | |
1529 | /* ------------------------------------------------------------------------- * |
1450 | /* ------------------------------------------------------------------------- * |
1530 | * CHILD PROCESS OPERATIONS * |
1451 | * CHILD PROCESS OPERATIONS * |
1531 | * ------------------------------------------------------------------------- */ |
1452 | * ------------------------------------------------------------------------- */ |
… | |
… | |
1575 | // unblock signals (signals are blocked by iom.C |
1496 | // unblock signals (signals are blocked by iom.C |
1576 | sigset_t ss; |
1497 | sigset_t ss; |
1577 | sigemptyset (&ss); |
1498 | sigemptyset (&ss); |
1578 | sigprocmask (SIG_SETMASK, &ss, 0); |
1499 | sigprocmask (SIG_SETMASK, &ss, 0); |
1579 | |
1500 | |
1580 | #ifndef __QNX__ |
|
|
1581 | /* command interpreter path */ |
1501 | /* command interpreter path */ |
1582 | if (argv != NULL) |
1502 | if (argv != NULL) |
1583 | { |
1503 | { |
1584 | # ifdef DEBUG_CMD |
1504 | # ifdef DEBUG_CMD |
1585 | int i; |
1505 | int i; |
… | |
… | |
1611 | |
1531 | |
1612 | execlp (shell, argv0, NULL); |
1532 | execlp (shell, argv0, NULL); |
1613 | /* no error message: STDERR is closed! */ |
1533 | /* no error message: STDERR is closed! */ |
1614 | } |
1534 | } |
1615 | |
1535 | |
1616 | #else /* __QNX__ uses qnxspawn () */ |
|
|
1617 | |
|
|
1618 | char iov_a[10] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; |
|
|
1619 | char *command = NULL, fullcommand[_MAX_PATH]; |
|
|
1620 | char **arg_v, *arg_a[2] = { NULL, NULL }; |
|
|
1621 | |
|
|
1622 | if (argv != NULL) |
|
|
1623 | { |
|
|
1624 | if (access (argv[0], X_OK) == -1) |
|
|
1625 | { |
|
|
1626 | if (strchr (argv[0], '/') == NULL) |
|
|
1627 | { |
|
|
1628 | searchenv (argv[0], "PATH", fullcommand); |
|
|
1629 | |
|
|
1630 | if (fullcommand[0] != '\0') |
|
|
1631 | command = fullcommand; |
|
|
1632 | } |
|
|
1633 | |
|
|
1634 | if (access (command, X_OK) == -1) |
|
|
1635 | return -1; |
|
|
1636 | } |
|
|
1637 | else |
|
|
1638 | command = argv[0]; |
|
|
1639 | |
|
|
1640 | arg_v = argv; |
|
|
1641 | } |
|
|
1642 | else |
|
|
1643 | { |
|
|
1644 | if ((command = getenv ("SHELL")) == NULL || *command == '\0') |
|
|
1645 | command = "/bin/sh"; |
|
|
1646 | |
|
|
1647 | arg_a[0] = my_basename (command); |
|
|
1648 | |
|
|
1649 | if (OPTION (Opt_loginShell)) |
|
|
1650 | { |
|
|
1651 | login = rxvt_malloc ((strlen (arg_a[0]) + 2) * sizeof (char)); |
|
|
1652 | |
|
|
1653 | login[0] = '-'; |
|
|
1654 | strcpy (&login[1], arg_a[0]); |
|
|
1655 | arg_a[0] = login; |
|
|
1656 | } |
|
|
1657 | |
|
|
1658 | arg_v = arg_a; |
|
|
1659 | } |
|
|
1660 | |
|
|
1661 | iov_a[0] = iov_a[1] = iov_a[2] = pty.tty; |
|
|
1662 | cmd_pid = qnx_spawn (0, 0, 0, -1, -1, |
|
|
1663 | _SPAWN_SETSID | _SPAWN_TCSETPGRP, |
|
|
1664 | command, arg_v, environ, iov_a, 0); |
|
|
1665 | if (login) |
|
|
1666 | free (login); |
|
|
1667 | |
|
|
1668 | pty.close_tty (); |
|
|
1669 | return pty.pty; |
|
|
1670 | #endif |
|
|
1671 | |
|
|
1672 | return -1; |
1536 | return -1; |
1673 | } |
1537 | } |
1674 | |
1538 | |
1675 | /*----------------------- end-of-file (C source) -----------------------*/ |
1539 | /*----------------------- end-of-file (C source) -----------------------*/ |