… | |
… | |
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); |
|
|
345 | |
|
|
346 | #if ENABLE_PERL |
|
|
347 | if (!rs[Rs_perl_ext_1]) |
|
|
348 | rs[Rs_perl_ext_1] = "default"; |
|
|
349 | |
|
|
350 | if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) |
|
|
351 | || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2]) |
|
|
352 | || (rs[Rs_perl_eval] && *rs[Rs_perl_eval])) |
|
|
353 | { |
|
|
354 | rxvt_perl.init (this); |
|
|
355 | HOOK_INVOKE ((this, HOOK_INIT, DT_END)); |
|
|
356 | } |
|
|
357 | #endif |
359 | |
358 | |
360 | /* |
359 | /* |
361 | * set any defaults not already set |
360 | * set any defaults not already set |
362 | */ |
361 | */ |
363 | if (cmd_argv && cmd_argv[0]) |
362 | if (cmd_argv && cmd_argv[0]) |
… | |
… | |
581 | * This should support all European type languages. |
580 | * This should support all European type languages. |
582 | */ |
581 | */ |
583 | void |
582 | void |
584 | rxvt_term::set_locale (const char *locale) |
583 | rxvt_term::set_locale (const char *locale) |
585 | { |
584 | { |
586 | TEMP_ENV; |
585 | set_environ (envv); |
587 | |
586 | |
588 | #if HAVE_XSETLOCALE || HAVE_SETLOCALE |
587 | #if HAVE_XSETLOCALE || HAVE_SETLOCALE |
589 | free (this->locale); |
588 | free (this->locale); |
590 | this->locale = setlocale (LC_CTYPE, locale); |
589 | this->locale = setlocale (LC_CTYPE, locale); |
591 | |
590 | |
… | |
… | |
622 | } |
621 | } |
623 | |
622 | |
624 | void |
623 | void |
625 | rxvt_term::init_xlocale () |
624 | rxvt_term::init_xlocale () |
626 | { |
625 | { |
627 | TEMP_ENV; |
626 | set_environ (envv); |
628 | |
627 | |
629 | #ifdef USE_XIM |
628 | #ifdef USE_XIM |
630 | if (!locale) |
629 | if (!locale) |
631 | rxvt_warn ("setting locale failed, working without locale support.\n"); |
630 | rxvt_warn ("setting locale failed, working without locale support.\n"); |
632 | else |
631 | else |
… | |
… | |
673 | if (strcmp (key_backspace, "DEC") == 0) |
672 | if (strcmp (key_backspace, "DEC") == 0) |
674 | priv_modes |= PrivMode_HaveBackSpace; |
673 | priv_modes |= PrivMode_HaveBackSpace; |
675 | #endif |
674 | #endif |
676 | |
675 | |
677 | /* add value for scrollBar */ |
676 | /* add value for scrollBar */ |
678 | if (scrollbar_visible ()) |
677 | if (scrollBar.state) |
679 | { |
678 | { |
680 | priv_modes |= PrivMode_scrollBar; |
679 | priv_modes |= PrivMode_scrollBar; |
681 | SavedModes |= PrivMode_scrollBar; |
680 | SavedModes |= PrivMode_scrollBar; |
682 | } |
|
|
683 | |
|
|
684 | if (menubar_visible ()) |
|
|
685 | { |
|
|
686 | priv_modes |= PrivMode_menuBar; |
|
|
687 | SavedModes |= PrivMode_menuBar; |
|
|
688 | } |
681 | } |
689 | |
682 | |
690 | run_command (argv); |
683 | run_command (argv); |
691 | } |
684 | } |
692 | |
685 | |
… | |
… | |
760 | if (!rs[Rs_color + Color_pointer_bg]) pix_colors[Color_pointer_bg] = pix_colors[Color_bg]; |
753 | 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]; |
754 | if (!rs[Rs_color + Color_border] ) pix_colors[Color_border] = pix_colors[Color_fg]; |
762 | } |
755 | } |
763 | |
756 | |
764 | /* |
757 | /* |
765 | * get scrollBar/menuBar shadow colors |
758 | * get scrollBar shadow colors |
766 | * |
759 | * |
767 | * The calculations of topShadow/bottomShadow values are adapted |
760 | * The calculations of topShadow/bottomShadow values are adapted |
768 | * from the fvwm window manager. |
761 | * from the fvwm window manager. |
769 | */ |
762 | */ |
770 | #ifdef KEEP_SCROLLCOLOR |
763 | #ifdef KEEP_SCROLLCOLOR |
… | |
… | |
925 | #if ENABLE_FRILLS |
918 | #if ENABLE_FRILLS |
926 | Atom prop = None; |
919 | Atom prop = None; |
927 | MWMHints mwmhints; |
920 | MWMHints mwmhints; |
928 | #endif |
921 | #endif |
929 | XGCValues gcvalue; |
922 | XGCValues gcvalue; |
930 | long vt_emask; |
|
|
931 | XSetWindowAttributes attributes; |
923 | XSetWindowAttributes attributes; |
932 | XWindowAttributes gattr; |
924 | XWindowAttributes gattr; |
933 | Window top, parent; |
925 | Window top, parent; |
934 | dDisp; |
926 | dDisp; |
935 | |
927 | |
… | |
… | |
945 | { |
937 | { |
946 | XGetWindowAttributes (disp, RootWindow (disp, display->screen), &gattr); |
938 | XGetWindowAttributes (disp, RootWindow (disp, display->screen), &gattr); |
947 | display->depth = gattr.depth; // doh //TODO, per-term not per-display? |
939 | display->depth = gattr.depth; // doh //TODO, per-term not per-display? |
948 | } |
940 | } |
949 | |
941 | |
|
|
942 | /* grab colors before netscape does */ |
|
|
943 | Get_Colours (); |
|
|
944 | |
|
|
945 | if (!set_fonts ()) |
|
|
946 | rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); |
|
|
947 | |
|
|
948 | parent = DefaultRootWindow (disp); |
|
|
949 | |
|
|
950 | attributes.override_redirect = !!OPTION (Opt_override_redirect); |
|
|
951 | |
950 | #if ENABLE_FRILLS |
952 | #if ENABLE_FRILLS |
951 | if (OPTION (Opt_borderLess)) |
953 | if (OPTION (Opt_borderLess)) |
952 | { |
954 | { |
953 | prop = XInternAtom(disp, "_MOTIF_WM_INFO", True); |
955 | prop = XInternAtom (disp, "_MOTIF_WM_INFO", True); |
954 | |
956 | |
955 | if (prop == None) |
957 | if (prop == None) |
956 | { |
958 | { |
957 | /* print_warning("Window Manager does not support MWM hints. Bypassing window manager control for borderless window.\n");*/ |
959 | /* 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; |
960 | attributes.override_redirect = TRUE; |
960 | #endif |
|
|
961 | mwmhints.flags = 0; |
961 | mwmhints.flags = 0; |
962 | } |
962 | } |
963 | else |
963 | else |
964 | { |
964 | { |
965 | mwmhints.flags = MWM_HINTS_DECORATIONS; |
965 | mwmhints.flags = MWM_HINTS_DECORATIONS; |
… | |
… | |
968 | } |
968 | } |
969 | else |
969 | else |
970 | mwmhints.flags = 0; |
970 | mwmhints.flags = 0; |
971 | #endif |
971 | #endif |
972 | |
972 | |
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 |
973 | #if ENABLE_XEMBED |
982 | if (rs[Rs_embed]) |
974 | if (rs[Rs_embed]) |
983 | { |
975 | { |
984 | XWindowAttributes wattr; |
976 | XWindowAttributes wattr; |
985 | |
977 | |
… | |
… | |
993 | #endif |
985 | #endif |
994 | |
986 | |
995 | window_calc (0, 0); |
987 | window_calc (0, 0); |
996 | |
988 | |
997 | /* sub-window placement & size in rxvt_resize_subwindows () */ |
989 | /* sub-window placement & size in rxvt_resize_subwindows () */ |
998 | #ifdef PREFER_24BIT |
|
|
999 | attributes.background_pixel = pix_colors_focused[Color_border]; |
990 | attributes.background_pixel = pix_colors_focused[Color_border]; |
1000 | attributes.border_pixel = pix_colors_focused[Color_border]; |
991 | attributes.border_pixel = pix_colors_focused[Color_border]; |
1001 | attributes.colormap = display->cmap; |
992 | attributes.colormap = display->cmap; |
1002 | top = XCreateWindow (disp, parent, |
993 | top = XCreateWindow (disp, parent, |
1003 | szHint.x, szHint.y, |
994 | szHint.x, szHint.y, |
1004 | szHint.width, szHint.height, |
995 | szHint.width, szHint.height, |
1005 | ext_bwidth, |
996 | ext_bwidth, |
1006 | display->depth, InputOutput, |
997 | display->depth, InputOutput, |
1007 | display->visual, |
998 | display->visual, |
1008 | CWColormap | CWBackPixel | CWBorderPixel, &attributes); |
999 | CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect, |
1009 | #else |
1000 | &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 | |
1001 | |
1018 | this->parent[0] = top; |
1002 | this->parent[0] = top; |
1019 | |
1003 | |
1020 | old_width = szHint.width; |
1004 | old_width = szHint.width; |
1021 | old_height = szHint.height; |
1005 | old_height = szHint.height; |
… | |
… | |
1075 | #endif |
1059 | #endif |
1076 | |
1060 | |
1077 | /* vt cursor: Black-on-White is standard, but this is more popular */ |
1061 | /* vt cursor: Black-on-White is standard, but this is more popular */ |
1078 | TermWin_cursor = XCreateFontCursor (disp, XC_xterm); |
1062 | TermWin_cursor = XCreateFontCursor (disp, XC_xterm); |
1079 | |
1063 | |
1080 | #if defined(HAVE_SCROLLBARS) || defined(MENUBAR) |
1064 | #ifdef HAVE_SCROLLBARS |
1081 | /* cursor (menuBar/scrollBar): Black-on-White */ |
1065 | /* cursor scrollBar: Black-on-White */ |
1082 | leftptr_cursor = XCreateFontCursor (disp, XC_left_ptr); |
1066 | leftptr_cursor = XCreateFontCursor (disp, XC_left_ptr); |
1083 | #endif |
1067 | #endif |
1084 | |
1068 | |
1085 | /* the vt window */ |
1069 | /* the vt window */ |
1086 | vt = XCreateSimpleWindow (disp, top, |
1070 | vt = XCreateSimpleWindow (disp, top, |
… | |
… | |
1098 | attributes.bit_gravity = NorthWestGravity; |
1082 | attributes.bit_gravity = NorthWestGravity; |
1099 | XChangeWindowAttributes (disp, vt, CWBitGravity, &attributes); |
1083 | XChangeWindowAttributes (disp, vt, CWBitGravity, &attributes); |
1100 | |
1084 | |
1101 | vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; |
1085 | vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; |
1102 | |
1086 | |
1103 | if (OPTION (Opt_pointerBlank) |
1087 | if (OPTION (Opt_pointerBlank)) |
1104 | #ifdef ENABLE_PERL |
|
|
1105 | || perl.self |
|
|
1106 | #endif |
|
|
1107 | ) |
|
|
1108 | vt_emask |= PointerMotionMask; |
1088 | vt_emask |= PointerMotionMask; |
1109 | else |
1089 | else |
1110 | vt_emask |= Button1MotionMask | Button3MotionMask; |
1090 | vt_emask |= Button1MotionMask | Button3MotionMask; |
1111 | |
1091 | |
1112 | XSelectInput (disp, vt, vt_emask); |
1092 | vt_select_input (); |
|
|
1093 | |
1113 | vt_ev.start (display, vt); |
1094 | 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 | |
1095 | |
1141 | #ifdef XPM_BACKGROUND |
1096 | #ifdef XPM_BACKGROUND |
1142 | if (rs[Rs_backgroundPixmap] != NULL |
1097 | if (rs[Rs_backgroundPixmap] != NULL |
1143 | && ! OPTION (Opt_transparent)) |
1098 | && ! OPTION (Opt_transparent)) |
1144 | { |
1099 | { |
… | |
… | |
1163 | GCForeground | GCBackground | GCGraphicsExposures, |
1118 | GCForeground | GCBackground | GCGraphicsExposures, |
1164 | &gcvalue); |
1119 | &gcvalue); |
1165 | |
1120 | |
1166 | drawable = new rxvt_drawable (display, vt); |
1121 | drawable = new rxvt_drawable (display, vt); |
1167 | |
1122 | |
1168 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
1123 | #ifdef RXVT_SCROLLBAR |
1169 | gcvalue.foreground = pix_colors[Color_topShadow]; |
1124 | gcvalue.foreground = pix_colors[Color_topShadow]; |
1170 | topShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); |
1125 | topShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); |
1171 | gcvalue.foreground = pix_colors[Color_bottomShadow]; |
1126 | gcvalue.foreground = pix_colors[Color_bottomShadow]; |
1172 | botShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); |
1127 | botShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); |
1173 | gcvalue.foreground = pix_colors[ (display->depth <= 2 ? Color_fg : Color_scroll)]; |
1128 | gcvalue.foreground = pix_colors[ (display->depth <= 2 ? Color_fg : Color_scroll)]; |
… | |
… | |
1413 | * the slave. |
1368 | * the slave. |
1414 | */ |
1369 | */ |
1415 | void |
1370 | void |
1416 | rxvt_term::run_command (const char *const *argv) |
1371 | rxvt_term::run_command (const char *const *argv) |
1417 | { |
1372 | { |
1418 | TEMP_ENV; // not very temporary... |
|
|
1419 | |
|
|
1420 | #if ENABLE_FRILLS |
1373 | #if ENABLE_FRILLS |
1421 | if (rs[Rs_pty_fd]) |
1374 | if (rs[Rs_pty_fd]) |
1422 | { |
1375 | { |
1423 | pty.pty = atoi (rs[Rs_pty_fd]); |
1376 | pty->pty = atoi (rs[Rs_pty_fd]); |
1424 | |
1377 | |
1425 | if (pty.pty >= 0) |
1378 | if (pty->pty >= 0) |
1426 | { |
1379 | { |
1427 | if (getfd_hook) |
1380 | if (getfd_hook) |
1428 | pty.pty = (*getfd_hook) (pty.pty); |
1381 | pty->pty = (*getfd_hook) (pty->pty); |
1429 | |
1382 | |
1430 | if (pty.pty < 0 || fcntl (pty.pty, F_SETFL, O_NONBLOCK)) |
1383 | if (pty->pty < 0 || fcntl (pty->pty, F_SETFL, O_NONBLOCK)) |
1431 | rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); |
1384 | rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); |
1432 | } |
1385 | } |
1433 | } |
1386 | } |
1434 | else |
1387 | else |
1435 | #endif |
1388 | #endif |
1436 | if (!pty.get ()) |
1389 | if (!pty->get ()) |
1437 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
1390 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
1438 | |
1391 | |
1439 | pty.set_utf8_mode (enc_utf8); |
1392 | pty->set_utf8_mode (enc_utf8); |
1440 | |
1393 | |
1441 | /* set initial window size */ |
1394 | /* set initial window size */ |
1442 | tt_winch (); |
1395 | tt_winch (); |
1443 | |
1396 | |
1444 | int er; |
1397 | int er; |
… | |
… | |
1457 | #if ENABLE_FRILLS |
1410 | #if ENABLE_FRILLS |
1458 | if (rs[Rs_pty_fd]) |
1411 | if (rs[Rs_pty_fd]) |
1459 | return; |
1412 | return; |
1460 | #endif |
1413 | #endif |
1461 | |
1414 | |
1462 | #ifndef __QNX__ |
|
|
1463 | /* spin off the command interpreter */ |
1415 | /* spin off the command interpreter */ |
1464 | switch (cmd_pid = fork ()) |
1416 | switch (cmd_pid = fork ()) |
1465 | { |
1417 | { |
1466 | case -1: |
1418 | case -1: |
1467 | { |
1419 | { |
… | |
… | |
1469 | rxvt_fatal ("can't fork, aborting.\n"); |
1421 | rxvt_fatal ("can't fork, aborting.\n"); |
1470 | } |
1422 | } |
1471 | case 0: |
1423 | case 0: |
1472 | init_env (); |
1424 | init_env (); |
1473 | |
1425 | |
1474 | if (!pty.make_controlling_tty ()) |
1426 | if (!pty->make_controlling_tty ()) |
1475 | fprintf (stderr, "%s: could not obtain control of tty.", RESNAME); |
1427 | fprintf (stderr, "%s: could not obtain control of tty.", RESNAME); |
1476 | else |
1428 | else |
1477 | { |
1429 | { |
1478 | /* Reopen stdin, stdout and stderr over the tty file descriptor */ |
1430 | /* Reopen stdin, stdout and stderr over the tty file descriptor */ |
1479 | dup2 (pty.tty, STDIN_FILENO); |
1431 | dup2 (pty->tty, STDIN_FILENO); |
1480 | dup2 (pty.tty, STDOUT_FILENO); |
1432 | dup2 (pty->tty, STDOUT_FILENO); |
1481 | dup2 (pty.tty, STDERR_FILENO); |
1433 | dup2 (pty->tty, STDERR_FILENO); |
1482 | |
1434 | |
1483 | // close all our file handles that we do no longer need |
1435 | // close all our file handles that we do no longer need |
1484 | for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++) |
1436 | for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++) |
1485 | { |
1437 | { |
1486 | if ((*t)->pty.pty > 2) close ((*t)->pty.pty); |
1438 | if ((*t)->pty->pty > 2) close ((*t)->pty->pty); |
1487 | if ((*t)->pty.tty > 2) close ((*t)->pty.tty); |
1439 | if ((*t)->pty->tty > 2) close ((*t)->pty->tty); |
1488 | } |
1440 | } |
1489 | |
1441 | |
1490 | run_child (argv); |
1442 | run_child (argv); |
1491 | fprintf (stderr, "%s: unable to exec child.", RESNAME); |
1443 | fprintf (stderr, "%s: unable to exec child.", RESNAME); |
1492 | } |
1444 | } |
1493 | |
1445 | |
1494 | _exit (EXIT_FAILURE); |
1446 | _exit (EXIT_FAILURE); |
1495 | |
1447 | |
1496 | default: |
1448 | 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 |
1449 | #if UTMP_SUPPORT |
1506 | privileged_utmp (SAVE); |
1450 | if (!OPTION (Opt_utmpInhibit)) |
|
|
1451 | pty->login (cmd_pid, OPTION (Opt_loginShell), rs[Rs_display_name]); |
1507 | #endif |
1452 | #endif |
1508 | |
1453 | |
1509 | #if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT) |
1454 | pty->close_tty (); |
1510 | |
1455 | |
1511 | dup2 (fdstdin, STDIN_FILENO); |
1456 | child_ev.start (cmd_pid); |
1512 | close (fdstdin); |
|
|
1513 | #endif |
|
|
1514 | } |
|
|
1515 | |
1457 | |
1516 | pty.close_tty (); /* keep STDERR_FILENO, pty.pty, display->fd () open */ |
1458 | HOOK_INVOKE ((this, HOOK_CHILD_START, DT_INT, cmd_pid, DT_END)); |
1517 | break; |
1459 | break; |
1518 | } |
1460 | } |
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 | } |
1461 | } |
1528 | |
1462 | |
1529 | /* ------------------------------------------------------------------------- * |
1463 | /* ------------------------------------------------------------------------- * |
1530 | * CHILD PROCESS OPERATIONS * |
1464 | * CHILD PROCESS OPERATIONS * |
1531 | * ------------------------------------------------------------------------- */ |
1465 | * ------------------------------------------------------------------------- */ |
… | |
… | |
1575 | // unblock signals (signals are blocked by iom.C |
1509 | // unblock signals (signals are blocked by iom.C |
1576 | sigset_t ss; |
1510 | sigset_t ss; |
1577 | sigemptyset (&ss); |
1511 | sigemptyset (&ss); |
1578 | sigprocmask (SIG_SETMASK, &ss, 0); |
1512 | sigprocmask (SIG_SETMASK, &ss, 0); |
1579 | |
1513 | |
1580 | #ifndef __QNX__ |
|
|
1581 | /* command interpreter path */ |
1514 | /* command interpreter path */ |
1582 | if (argv != NULL) |
1515 | if (argv != NULL) |
1583 | { |
1516 | { |
1584 | # ifdef DEBUG_CMD |
1517 | # ifdef DEBUG_CMD |
1585 | int i; |
1518 | int i; |
… | |
… | |
1611 | |
1544 | |
1612 | execlp (shell, argv0, NULL); |
1545 | execlp (shell, argv0, NULL); |
1613 | /* no error message: STDERR is closed! */ |
1546 | /* no error message: STDERR is closed! */ |
1614 | } |
1547 | } |
1615 | |
1548 | |
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; |
1549 | return -1; |
1673 | } |
1550 | } |
1674 | |
1551 | |
1675 | /*----------------------- end-of-file (C source) -----------------------*/ |
1552 | /*----------------------- end-of-file (C source) -----------------------*/ |