comparison srogue/command.c @ 119:458df24e973d

srogue: use functions from mdport.c. Shell escape, passwd entries, terminal settings, and most signal handling is now done with the more portable md_* functions.
author John "Elwin" Edwards
date Wed, 30 Apr 2014 14:46:30 -0700
parents 1e88eb1942a5
children 576cc8154521
comparison
equal deleted inserted replaced
118:8d1dfc5a912c 119:458df24e973d
367 { 367 {
368 reg char ch, good; 368 reg char ch, good;
369 /* 369 /*
370 * Reset the signal in case we got here via an interrupt 370 * Reset the signal in case we got here via an interrupt
371 */ 371 */
372 #ifdef SIGINT
372 if (signal(SIGINT, quit) != quit) 373 if (signal(SIGINT, quit) != quit)
373 mpos = 0; 374 mpos = 0;
375 #endif
374 msg("Really quit? [y/n/s]"); 376 msg("Really quit? [y/n/s]");
375 /* ch = tolower(readchar());*/ 377 /* ch = tolower(readchar());*/
376 ch = readchar(); 378 ch = readchar();
377 if (ch == 'y') { 379 if (ch == 'y') {
378 clear(); 380 clear();
393 endwin(); 395 endwin();
394 byebye(0); 396 byebye(0);
395 } 397 }
396 } 398 }
397 else { 399 else {
400 #ifdef SIGINT
398 signal(SIGINT, quit); 401 signal(SIGINT, quit);
402 #endif
399 wmove(cw, 0, 0); 403 wmove(cw, 0, 0);
400 wclrtoeol(cw); 404 wclrtoeol(cw);
401 draw(cw); 405 draw(cw);
402 mpos = 0; 406 mpos = 0;
403 count = 0; 407 count = 0;
635 in_shell = TRUE; 639 in_shell = TRUE;
636 fflush(stdout); 640 fflush(stdout);
637 /* 641 /*
638 * Fork and do a shell 642 * Fork and do a shell
639 */ 643 */
640 #ifndef __DJGPP__ 644 md_shellescape();
641 while((pid = fork()) < 0) 645 printf("\n%s", retstr);
642 sleep(1); 646 fflush(stdout);
643 if (pid == 0) { 647 nonl();
644 setuid(playuid); /* Set back to original user */ 648 noecho();
645 setgid(playgid); 649 crmode();
646 execl(sh == NULL ? "/bin/sh" : sh, "shell", "-i", 0); 650 in_shell = FALSE;
647 perror("No shelly"); 651 wait_for(cw, '\n');
648 byebye(-1); 652 restscr(cw);
649 }
650 else {
651 signal(SIGINT, SIG_IGN);
652 signal(SIGQUIT, SIG_IGN);
653 while (wait(&ret_status) != pid)
654 continue;
655 signal(SIGINT, quit);
656 signal(SIGQUIT, endit);
657
658 #else
659 {
660 char shell[PATH_MAX];
661
662 if (sh && *sh)
663 strncpy(shell,sh,PATH_MAX);
664 else
665 sprintf(shell, "%s\\bin\\sh.exe", getenv("DJDIR"));
666
667 if (spawnl(P_WAIT,shell, "shell", "-i", 0) == -1)
668 msg("No shelly: %s", shell);
669
670 #endif
671 printf("\n%s", retstr);
672 fflush(stdout);
673 nonl();
674 noecho();
675 crmode();
676 in_shell = FALSE;
677 wait_for(cw, '\n');
678 restscr(cw);
679 }
680 } 653 }
681 654
682 655
683 /* 656 /*
684 * call: 657 * call: