Skip to content

Commit 4aad16e

Browse files
committed
tty: write filename in a file, don't symlink to /dev
If the osquery tool[1] is running and scanning a directory containing the `tty` symlink, it will follow the link to `/dev/ttys*` and start some kind of infinite loop involving the debug console. This causes hyperkit's CPU to spike and for the console itself to be spammed with it's own output. The easiest workaround is to not create the symlink, but write the name of the tty in a file instead. Therefore for debugging we can still run ``` screen $(cat ~/Library/Containers/com.docker.docker/Data/vms/0/tty) ``` (or equivalent) Reported originally around here[2] [1] https://osquery.io/downloads/ [2] docker/for-mac#3499 (comment) Signed-off-by: David Scott <dave@recoil.org>
1 parent 461b3f9 commit 4aad16e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/lib/uart_emul.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -758,14 +758,16 @@ uart_set_backend(struct uart_softc *sc, const char *backend, const char *devname
758758

759759
if (linkname) {
760760
if ((unlink(linkname) == -1) && (errno != ENOENT)) {
761-
perror("unlinking autopty symlink");
761+
perror("unlinking autopty file");
762762
goto err;
763763
}
764-
if (symlink(ptyname, linkname) == -1){
765-
perror("creating autopty symlink");
764+
int namefd = open(linkname, O_CREAT | O_WRONLY);
765+
if (namefd == -1) {
766+
perror("creating autopty file");
766767
goto err;
767768
}
768-
fprintf(stdout, "%s linked to %s\n", devname, linkname);
769+
(void) write(namefd, ptyname, strlen(ptyname));
770+
(void) close(namefd);
769771
}
770772

771773
sc->tty.fd = ptyfd;

0 commit comments

Comments
 (0)