| delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
| :list-unsubscribe:list-subscribe:list-archive:list-post | |
| :list-help:sender:date:from:to:subject:message-id:in-reply-to | |
| :references:mime-version:content-type:content-transfer-encoding; | |
| q=dns; s=default; b=nYtQ+3OW1z4cMmihPxgzDoXPEk4CiskUqtQ1PYojIsN | |
| 21Gimdq7z81doLIBi+qYdeBGPTh07Jz+Wrm+YkaGWBLQuonK5s+d8FhlP3UHH1r7 | |
| tTGxUd4HvYscUF8p6JHYTRSsextr1ipJDJIspSx6VEKu8Eaq6aifD4W5aG3sAaeI | |
| = | |
| DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id |
| :list-unsubscribe:list-subscribe:list-archive:list-post | |
| :list-help:sender:date:from:to:subject:message-id:in-reply-to | |
| :references:mime-version:content-type:content-transfer-encoding; | |
| s=default; bh=oux/boziD60UmX1JWXc/5qqKOxI=; b=TCHSbVUCpt73WxydS | |
| egwi+v5w+dCmzTl29CK/ySIbxxTln7vQ7yjf9unM+vBzMt84zuybDYMuASdZ+bqW | |
| vrFBK0JbQf3Uhr88mIqC0DDk1tXQ9M3mG37ggst91JCR/xvhKFlTYDZ1rRvLFpSx | |
| Uavbw20qzOTR3bTBTpyG2S51Hw= | |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.com> |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
| Authentication-Results: | sourceware.org; auth=none |
| X-Virus-Found: | No |
| X-Spam-SWARE-Status: | No, score=-1.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_SORBS_DUL,SPF_PASS autolearn=ham version=3.3.2 |
| X-HELO: | conuserg003-v.nifty.com |
| X-Nifty-SrcIP: | [121.93.68.199] |
| Date: | Fri, 6 Mar 2015 20:07:10 +0900 |
| From: | Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp> |
| To: | cygwin AT cygwin DOT com |
| Subject: | Re: PTY dies when master in parent process is closed. |
| Message-Id: | <20150306200710.1264a46aa8dd633943e56212@nifty.ne.jp> |
| In-Reply-To: | <20150305135839.GZ3213@calimero.vinschen.de> |
| References: | <20150305215323 DOT 760df4752fdbd6f19a931851 AT nifty DOT ne DOT jp> <20150305133100 DOT GY3213 AT calimero DOT vinschen DOT de> <20150305135839 DOT GZ3213 AT calimero DOT vinschen DOT de> |
| Mime-Version: | 1.0 |
| X-IsSubscribed: | yes |
On Thu, 5 Mar 2015 14:58:39 +0100
Corinna Vinschen <corinna-cygwin AT cygwin DOT com> wrote:
> I applied a patch. Please have a look.
I have tested the latest CVS version, and found
a new problem.
With new CVS version, slave side can not detect
closure of master.
Please use following Test Case 3. Test Case 3 is
not terminated by itself with latest CVS.
It seems that the program is stopping at
cygwait(input_available_event, time_to_wait)
in fhandler_pty_slave::read().
I guess input_available_event should be set when
the last valid master fd is closed.
/***************/
/* Test Case 3 */
/***************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <pty.h>
#include <wait.h>
int main()
{
int master, slave;
pid_t pid;
if ( openpty(&master, &slave, NULL, NULL, NULL) < 0) {
perror("openpty()");
exit(EXIT_FAILURE);
}
pid = fork();
if (pid < 0) {
perror("fork()");
exit(EXIT_FAILURE);
}
if (pid != 0) { /* Parent */
close(slave);
write(master, "0123456789\n", 11);
usleep(100000); /* wait for slave read() */
close(master);
wait(NULL);
} else { /* Child */
close(master);
for (;;) {
char buf[BUFSIZ];
int len = read(slave, buf, sizeof(buf));
if (len <= 0) {
perror("read()");
break;
}
write(STDOUT_FILENO, buf, len);
}
close(slave);
}
return EXIT_SUCCESS;
}
--
Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |