Ronald Oussoren <ronaldousso...@mac.com> added the comment:

This is IMHO not a bug in Python, the problem can been seen when you rewrite 
the code in msg170261 in C, see the code below.

An observation with the C code below: Both moving ``close(slave)`` to above the 
sleep or removing that close entirely fixes the problem for me. Likewise with 
adding ``usleep(700000);`` to the child before exiting.

It is unclear to me who's at fault here, this could be a bug in the macOS 
kernel but could also be a bug in this code.  It looks like the output is lost 
when ``close(slave)`` happens after the child proces has exited.

BTW. All testing was done on macOS 10.14.5, with python 3.8.

Anyway: I propose closing this issue because this is not a bug in CPython.


/* The C code used to test system behaviour */
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <util.h>



int main(void)
{
        int master, slave;
        int r;
        pid_t pid;

        r = openpty(&master, &slave, NULL, NULL, NULL);
        if (r == -1) {
                perror("openpty");
                exit(1);
        }

        pid = fork();

        if (pid == 0) {
                /* child */
                setsid();
                close(master);

                dup2(slave, 0);
                dup2(slave, 1);
                dup2(slave, 2);
                close(slave);

                write(1, "testing", 7);
                _exit(255);
        } else {
                /* parent */
                char buf[1024];

                usleep(500000); /* 0.5 */
                close(slave);

                r = read(master, buf, 1024);
                if (r == -1) {
                        perror("read");
                        exit(1);
                }

                printf("%d\n", r);
                write(1, buf, r);

                kill(pid, SIGKILL);
        }
}

----------
resolution:  -> not a bug
status: open -> pending
versions: +Python 3.7, Python 3.8, Python 3.9 -Python 2.6, Python 3.1, Python 
3.2

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue15898>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to