nanogui: X11 works well


Previous by date: 4 Dec 1999 06:29:34 -0000 Re: Porting of Microwindows to RTEMS., Rosimildo daSilva
Next by date: 4 Dec 1999 06:29:34 -0000 fonts in nanox, Chris Ross
Previous in thread: 4 Dec 1999 06:29:34 -0000 Re: X11 works well, Greg Haerr
Next in thread:

Subject: Re: X11 works well
From: Daniel R Risacher ####@####.####
Date: 4 Dec 1999 06:29:34 -0000
Message-Id: <m2wvqvp6pa.fsf@alum.mit.edu>

My sincere apologies for my previous message, which contained a patch
that wouldn't apply correctly.  Somehow, in preparing the message, the
whitespace in the patch got garbled up.  Mea culpa.

Here it is again.  Hopefully more correct this time.

(Alert readers are warned that Greg's message may include a simpler
solution that I haven't tried yet..) 

--- demos/microwin/mterm.c.old	Fri Dec  3 07:03:39 1999
+++ demos/microwin/mterm.c	Fri Dec  3 07:16:23 1999
@@ -248,15 +248,16 @@
 	char *	argv[2];
 
 again:
-	sprintf(pty_name, "/dev/ptyp%d", n);
-	if ((tfd = open(pty_name, O_RDWR | O_NONBLOCK)) < 0) {
-		if ((errno == EBUSY) && (n < 3)) {
-			++n;
-			goto again;
-		}
-		fprintf(stderr, "Can't create pty %s\n", pty_name);
+        if ((tfd = getpt())<0) {
+		fprintf(stderr, "Can't create master pty\n");
 		return -1;
 	}
+
+        if (grantpt(tfd)) 
+                perror("failure");
+        if (unlockpt(tfd)) 
+                perror("failure");
+
 	signal(SIGCHLD, ptysignaled);
 	signal(SIGINT, ptysignaled);
 	if ((pid = fork()) == -1) {
@@ -264,13 +265,13 @@
 		return -1;
 	}
 	if (!pid) {
+                ptsname_r(tfd, pty_name, 12);
 		close(STDIN_FILENO);
 		close(STDOUT_FILENO);
 		close(STDERR_FILENO);
 		close(tfd);
 		
 		setsid();
-		pty_name[5] = 't';
 		if ((tfd = open(pty_name, O_RDWR)) < 0) {
 			fprintf(stderr, "Child: Can't open pty %s\n", pty_name);
 			exit(1);
--- demos/nanox/nterm.c.old	Fri Dec  3 07:03:39 1999
+++ demos/nanox/nterm.c	Fri Dec  3 07:16:20 1999
@@ -162,15 +162,16 @@
 	pid_t pid;
 
 again:
-	sprintf(pty_name, "/dev/ptyp%d", n);
-	if ((tfd = open(pty_name, O_RDWR | O_NONBLOCK)) < 0) {
-		if ((errno == EBUSY || errno == EIO) && n < 10) {
-			n++;
-			goto again;
-		}
-		fprintf(stderr, "Can't create pty %s\n", pty_name);
+        if ((tfd = getpt())<0) {
+		fprintf(stderr, "Can't create master pty\n");
 		return -1;
 	}
+
+        if (grantpt(tfd)) 
+                perror("failure");
+        if (unlockpt(tfd)) 
+                perror("failure");
+
 	signal(SIGCHLD, sigchild);
 	signal(SIGINT, sigchild);
 	if ((pid = fork()) == -1) {
@@ -178,13 +179,13 @@
 		return -1;
 	}
 	if (!pid) {
+                ptsname_r(tfd, pty_name, 12);
 		close(STDIN_FILENO);
 		close(STDOUT_FILENO);
 		close(STDERR_FILENO);
 		close(tfd);
 		
 		setsid();
-		pty_name[5] = 't';
 		if ((tfd = open(pty_name, O_RDWR)) < 0) {
 			fprintf(stderr, "Child: Can't open pty %s\n", pty_name);
 			exit(1);


-- 
               "So, shall we go act innocent now?"

Daniel Risacher                                   ####@####.####

Previous by date: 4 Dec 1999 06:29:34 -0000 Re: Porting of Microwindows to RTEMS., Rosimildo daSilva
Next by date: 4 Dec 1999 06:29:34 -0000 fonts in nanox, Chris Ross
Previous in thread: 4 Dec 1999 06:29:34 -0000 Re: X11 works well, Greg Haerr
Next in thread:


Powered by ezmlm-browse 0.20.