Skip to main content

closeallelse

Function closeallelse 

Source
pub fn closeallelse(mn: &multio)
Expand description

Port of static void closeallelse(struct multio *mn) from Src/exec.c:2358.

C body:

int i, j;
long openmax;
openmax = fdtable_size;
for (i = 0; i < openmax; i++)
    if (mn->pipe != i) {
        for (j = 0; j < mn->ct; j++)
            if (mn->fds[j] == i) break;
        if (j == mn->ct)
            zclose(i);
    }

Close every fd in the open range EXCEPT mn->pipe and the fds stashed in mn->fds. Called inside the multio tee/cat child process to release every fd the parent had open — only the pipe

  • per-output fds stay alive for the read/write loop.