Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Close *all* file descriptors



On Sun, May 22, 2022 at 08:17:58PM +0100, Dominik Vogt wrote:
> On Sun, May 22, 2022 at 05:49:50AM -0500, Zach Riggle wrote:
> > Unfortunately, macOS does not support proofs, so there???s no nice way to do
> > it the way you recommended.
> >
> > I can just force-close the first 1024 file descriptors that I don???t care
> > about, and hope that it???s sufficient.
>
> Does this help?
>
>   $ for FD in $(lsof -p $$ |
>                 tr -s " " |
>                 cut -f 4 -d " " |
>                 grep "^[0-9]*[urw]$" |
>                 sed -e "s/[urw]$//"); do
>         # close/redirect FD or whatever
>         :
>     done

Or simpler:

  $ ...  $(lsof -p $$ -F F | grep "^f[0-9]*$" | tr -d f) ...

Ciao

Dominik ^_^  ^_^

--

Dominik Vogt




Messages sorted by: Reverse Date, Date, Thread, Author