Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Hang in E01 due to zpty on OpenBSD
- X-seq: zsh-workers 49977
- From: Matthew Martin <phy1729@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Hang in E01 due to zpty on OpenBSD
- Date: Sun, 3 Apr 2022 16:42:24 -0500
- Archived-at: <https://zsh.org/workers/49977>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: zsh-workers@xxxxxxx
E01 hangs on OpenBSD-current when run as the _pbuild user. The line that
hangs is L1435
zpty subshell $ZTST_testdir/../Src/zsh -f +Z
which is because the read call in Modules/zpty.c L472
ret = read(master, &syncch, 1);
never returns. I believe this is because the forked child fails to open
the corresponding tty when get_pty is called on 362 and the child exits.
I assume the EPERM on open is an OpenBSD bug, but zsh should probably
not hang either.
I'd appreciate if anyone could confirm the below is an accurate minimal
reproducer to report to OpenBSD.
#include <err.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
static int
get_pty(char *path) {
const char char1[] = "pqrstuvwxyzPQRST";
const char char2[] = "0123456789"
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const char *p1, *p2;
int fd;
strcpy(path, "/dev/ptyxx");
for (p1 = char1; *p1; p1++) {
path[8] = *p1;
for (p2 = char2; *p2; p2++) {
path[9] = *p2;
if ((fd = open(path, O_RDWR|O_NOCTTY)) >= 0) {
return fd;
}
}
}
return -1;
}
int
main() {
char path[11];
int ptyfd, ttyfd;
if ((ptyfd = get_pty(path)) == -1) {
err(1, "get_pty");
}
printf("%d: %s\n", ptyfd, path);
path[5] = 't';
if ((ttyfd = open(path, O_RDWR|O_NOCTTY)) == -1) {
err(1, "open");
}
printf("%d: %s\n", ttyfd, path);
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author