diff 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
line wrap: on
line diff
--- a/srogue/command.c	Sun Apr 27 08:29:14 2014 -0700
+++ b/srogue/command.c	Wed Apr 30 14:46:30 2014 -0700
@@ -369,8 +369,10 @@
 	/*
 	 * Reset the signal in case we got here via an interrupt
 	 */
+#ifdef SIGINT
 	if (signal(SIGINT, quit) != quit)
 		mpos = 0;
+#endif
 	msg("Really quit? [y/n/s]");
 /*	ch = tolower(readchar());*/
 	ch = readchar();
@@ -395,7 +397,9 @@
 		}
 	}
 	else {
+#ifdef SIGINT
 		signal(SIGINT, quit);
+#endif
 		wmove(cw, 0, 0);
 		wclrtoeol(cw);
 		draw(cw);
@@ -637,46 +641,15 @@
 	/*
 	 * Fork and do a shell
 	 */
-#ifndef __DJGPP__
-	while((pid = fork()) < 0)
-		sleep(1);
-	if (pid == 0) {
-		setuid(playuid);	/* Set back to original user */
-		setgid(playgid);
-		execl(sh == NULL ? "/bin/sh" : sh, "shell", "-i", 0);
-		perror("No shelly");
-		byebye(-1);
-	}
-	else {
-		signal(SIGINT, SIG_IGN);
-		signal(SIGQUIT, SIG_IGN);
-		while (wait(&ret_status) != pid)
-			continue;
-		signal(SIGINT, quit);
-		signal(SIGQUIT, endit);
-
-#else
-	{
-		char shell[PATH_MAX];
-
-		if (sh && *sh)
-			strncpy(shell,sh,PATH_MAX);
-		else
-			sprintf(shell, "%s\\bin\\sh.exe", getenv("DJDIR"));
-
-		if (spawnl(P_WAIT,shell, "shell", "-i", 0) == -1)
-			msg("No shelly: %s", shell);
-
-#endif
-		printf("\n%s", retstr);
-		fflush(stdout);
-		nonl();
-		noecho();
-		crmode();
-		in_shell = FALSE;
-		wait_for(cw, '\n');
-		restscr(cw);
-	}
+	md_shellescape();
+	printf("\n%s", retstr);
+	fflush(stdout);
+	nonl();
+	noecho();
+	crmode();
+	in_shell = FALSE;
+	wait_for(cw, '\n');
+	restscr(cw);
 }