Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Duplicating file descriptor 10
- X-seq: zsh-users 30745
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Cc: john@xxxxxxxxxxxxxxxx
- Subject: Re: Duplicating file descriptor 10
- Date: Thu, 15 Oct 2026 20:42:48 -0700
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=4UhFlLQDRvbF5Jwfq0EjHjfsssUh7KpxH5dOiKvj9Qg=; fh=h6SLlP9914avtm1x20YcsbdCWwiIHXxTUP+oqqWl710=; b=Y+36clCoHcXosVpyn0Qd4mi8lu3xb1n7NoWJUVO6XgAncbWaI50tXhWW+E/SqLUMQ0 pAxHGRR3s4aZPbkHNYw9T6XAkqx4mzTCZxqv6QFmKknks0Wr2GI7bGq1dXXP+MRlsDNN yn3cy7uG7eB40DI/na75ztnigV9+eYjIvJgM1FHqnhCeUeVwFxSBCGU/uK74ufRNe4wZ eAOd+93Qrx4gRZldpSDQ+DLIueTJP8NH1FhiCTTDwAv2X4kQH3NjSQtskICsU4aWHyp5 uR8HB9aN3J0RdUev2sIEPYETo6eaNtwvv/KBLl3hji02tz0sKe/DlZTipjg7g9X5AI+4 NCAw==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1792122180; cv=none; d=google.com; s=arc-20260327; b=aSGLf71bkj3IypR5dKAcuG+rJO22RTMpn5KJ//yZNfk5+9t9WmamciVrj9AKI1+3aa nlSYSjoUe8WFstfeyMy7UzZqtojEC5tu/PFoPQeontNd3AkUqXry1HwzT1sCHHRx8vxR fdGNL6KO63vVYzcjLPtFABoo7vV5UKNRBWoT+qYux6mtB8368aMMogBYVXh73Uk7fyyv EfB0no/769OGABEQtaeuxIks/ODLXZvWQzJMXFm1Nl2cqOpHQPNa6Ag5aAC4MnzzpY55 a1wf3ZySpmoK23pajFnDcJ0v0fJvWtNL7WJHjVynkNi0yQPdDrYe4eNVsRWIKe+NTnzv h/Qw==
- Archived-at: <https://zsh.org/users/30745>
- In-reply-to: <9786ED8B-7EE5-484C-8FE0-DAB398F525EF@gaelicwizard.net>
- List-id: <zsh-users.zsh.org>
- References: <9786ED8B-7EE5-484C-8FE0-DAB398F525EF@gaelicwizard.net>
On Thu, Oct 15, 2026 at 7:42 PM John Pell <john@xxxxxxxxxxxxxxxx> wrote:
>
> Zsh duplicates the tty (from stdin) to fd 10, which is exactly what I’m looking for, except… I can’t write to fd 10. I can’t dup fd 10.
Zsh reserves the first available fd greater than 9 to be its internal
copy of fd 0 because it sometimes needs to dup it back to 0 again for
proper operation. It therefore protects it from being manipulated by
shell redirections, and forces errno = EBADF if you try. Note this
isn't always fd 10, if the calling process has opened 10 and left it
that way, this reserved fd moves to 11.
> The goal here is to be able to print to the tty even if stdin/stdout/stderr are redirected elsewhere at various times.
The reserved fd is not guaranteed to be connected to a TTY, though it
would be in an interactive shell.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author