[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs shell.c
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs shell.c |
Date: |
Tue, 08 Apr 2008 09:29:38 +0000 |
CVSROOT: /cvsroot/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 08/04/08 09:29:38
Modified files:
. : shell.c
Log message:
fixed pseudo-tty allocation using Unix98 API
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/shell.c?cvsroot=qemacs&r1=1.48&r2=1.49
Patches:
Index: shell.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/shell.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -b -r1.48 -r1.49
--- shell.c 8 Apr 2008 09:25:16 -0000 1.48
+++ shell.c 8 Apr 2008 09:29:38 -0000 1.49
@@ -19,6 +19,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#define _GNU_SOURCE
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -81,11 +83,11 @@
/* move to mode */
static int shell_launched = 0;
-#define PTYCHAR1 "pqrstuvwxyz"
+#define PTYCHAR1 "pqrstuvwxyzabcde"
#define PTYCHAR2 "0123456789abcdef"
/* allocate one pty/tty pair */
-static int get_pty(char *tty_str)
+static int get_pty(char *tty_str, int size)
{
int fd;
char ptydev[] = "/dev/pty??";
@@ -93,6 +95,13 @@
int len = strlen(ttydev);
const char *c1, *c2;
+ /* First try Unix98 pseudo tty master */
+ if ((fd = open("/dev/ptmx", O_RDWR)) >= 0) {
+ if (!ptsname_r(fd, tty_str, size) && !grantpt(fd) && !unlockpt(fd))
+ return fd;
+ close(fd);
+ }
+ /* then try BSD pseudo tty pre-created pairs */
for (c1 = PTYCHAR1; *c1; c1++) {
ptydev[len-2] = ttydev[len-2] = *c1;
for (c2 = PTYCHAR2; *c2; c2++) {
@@ -121,9 +130,9 @@
char tty_name[32];
struct winsize ws;
- pty_fd = get_pty(tty_name);
+ pty_fd = get_pty(tty_name, sizeof(tty_name));
if (pty_fd < 0) {
- put_status(NULL, "run_process: cannot get tty");
+ put_status(NULL, "run_process: cannot get tty: %m");
return -1;
}
fcntl(pty_fd, F_SETFL, O_NONBLOCK);
- [Qemacs-commit] qemacs shell.c, Charlie Gordon, 2008/04/04
- [Qemacs-commit] qemacs shell.c, Charlie Gordon, 2008/04/04
- [Qemacs-commit] qemacs shell.c, Charlie Gordon, 2008/04/04
- [Qemacs-commit] qemacs shell.c,
Charlie Gordon <=
- [Qemacs-commit] qemacs shell.c, Charlie Gordon, 2008/04/08
- [Qemacs-commit] qemacs shell.c, Charlie Gordon, 2008/04/10
- [Qemacs-commit] qemacs shell.c, Charlie Gordon, 2008/04/12
- [Qemacs-commit] qemacs shell.c, Charlie Gordon, 2008/04/12
- [Qemacs-commit] qemacs shell.c, Charlie Gordon, 2008/04/13
- [Qemacs-commit] qemacs shell.c, Charlie Gordon, 2008/04/20