There's several conditions in which this is racy. Specifically, when a program writes large amounts into both STDOUT and STDERR, poll will return 2 (data is available on both PTYs), and I have no way of telling them apart.
I am using two PTYs to do the fancy splitting between STDOUT and STDERR. If I abandon this feature, I can just let the kernel sort out the ordering.
I have several choices here:
Rewrite this using ptrace (has its own downsides due to ptrace limitations)
Just always prefer either of the two PTYs in the case of a race
Abandon the double-pty line buffering and just use a singular pty (this prevents the nice (O) and (E) division)
Patch the kernel to allow unbuffered, blocking writes on PTYs (maybe something like flock that forces blocks)
Try to make it as fast as possible to print faster than writing happens, to minimize conflicts
I added a flag, --kernel-order that just uses a singular PTY.
There's several conditions in which this is racy. Specifically, when a program writes large amounts into both STDOUT and STDERR, poll will return 2 (data is available on both PTYs), and I have no way of telling them apart.
I am using two PTYs to do the fancy splitting between STDOUT and STDERR. If I abandon this feature, I can just let the kernel sort out the ordering.
I have several choices here:
- Rewrite this using ptrace (has its own downsides due to ptrace limitations)
- Just always prefer either of the two PTYs in the case of a race
- Abandon the double-pty line buffering and just use a singular pty (this prevents the nice (O) and (E) division)
- Patch the kernel to allow unbuffered, blocking writes on PTYs (maybe something like flock that forces blocks)
- Try to make it as fast as possible to print faster than writing happens, to minimize conflicts
I added a flag, `--kernel-order` that just uses a singular PTY.
There's several conditions in which this is racy. Specifically, when a program writes large amounts into both STDOUT and STDERR, poll will return 2 (data is available on both PTYs), and I have no way of telling them apart.
I am using two PTYs to do the fancy splitting between STDOUT and STDERR. If I abandon this feature, I can just let the kernel sort out the ordering.
I have several choices here:
I added a flag,
--kernel-orderthat just uses a singular PTY.