minimum # of open file limit? - Unix

This is a discussion on minimum # of open file limit? - Unix ; Hi. As long as I understood, when main() is started, thet C start-up code opens three files (stdin, stdout, and stderr). To verify this, consider this small program (a.out): int main(void) { return 0; } When I limit the maximum ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: minimum # of open file limit?

  1. minimum # of open file limit?

    Hi.

    As long as I understood, when main() is started, thet C start-up code
    opens three files (stdin, stdout, and stderr). To verify this,
    consider this small program (a.out):

    int main(void)
    {
    return 0;
    }

    When I limit the maximum # of open file to 3 using ulimit,
    the program failed to run:

    $ ulimit -n 3
    $ ./a.out
    -bash: start_pipeline: pgrp pipe: Too many open files
    -bash: ./a.out: Too many open files
    $ _

    To run this program, I need to set the # to 4 (not 3.):

    # In another shell
    $ ulimit -n 4
    $ ./a.out
    -bash: start_pipeline: pgrp pipe: Too many open files
    $ _

    My questions are:

    1. Why it needs 4 files to run a.out? Shouldn't 3 files
    be enough? What's the purpose of the last 1 file?

    2. What's the meaning of the "start_pipeple: pgrp pipe..."?
    It seems that bash uses another file to do
    something... Can I suppress this warning?
    Perhaps using some options when starting bash?

    Thanks in advance.

  2. Re: minimum # of open file limit?

    On Aug 25, 6:57*am, cinsk wrote:

    > As long as I understood, when main() is started, the C start-up code
    > opens three files (stdin, stdout, and stderr).


    This is incorrect. Those three files are already open when the process
    starts.

    > When I limit the maximum # of open file to 3 using ulimit,
    > the program failed to run:
    >
    > $ ulimit -n 3
    > $ ./a.out
    > *-bash: start_pipeline: pgrp pipe: Too many open files
    > -bash: ./a.out: Too many open files
    > $ _
    >
    > To run this program, I need to set the # to 4 (not 3.):


    This is not the programming failing to run, this is your shell being
    unable to do what it needs to do to start the program.

    > # In another shell
    > $ ulimit -n 4
    > $ ./a.out
    > -bash: start_pipeline: pgrp pipe: Too many open files
    > $ _
    >
    > My questions are:
    >
    > 1. Why it needs 4 files to run a.out? Shouldn't 3 files
    > * *be enough? * What's the purpose of the last 1 file?


    The "it" here is the shell. The shell presumably is already using
    three files at least, its stdin, stdout, and stderr. That means it
    cannot open even a single additional file.

    > 2. What's the meaning of the "start_pipeple: pgrp pipe..."?
    > * *It seems that bash uses another file to do
    > * *something... * Can I suppress this warning?
    > * *Perhaps using some options when starting bash?


    This is not a warning, it's an error. You are asking bash to do things
    in a circumstance where it cannot open even a single additional file.
    This means that anything bash does that requires opening even a single
    file cannot be done.

    DS

+ Reply to Thread