Hi mates!)
If somebody can - please explain me - what does mean "the lowest" in this context -

The open() function shall return a file descriptor for the named file that is the lowest file descriptor not currently open for that process.

the QUOTE is from here - http://pubs.opengroup.org/onlinepubs/

and one more question - what is the third parameter of open() function - for which it is used for example here -

int fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, [B][U]0666[/U][/B]];

Big thanks in advance!)

The operating system will use the next lowest file descriptor for that application. It really makes sense if you think about it. Would you expect the operating system to return a random number?

The third value is used if open creates a new file, its the umask value that's applied to the newly created file.

Comments
+++++++++++

File descriptors are just integers. The management of them is hidden from you, the user, but when they are provided it seems that open will select the lowest integer not currently associated with an open file for your process. In general, stdin, stdout, stderr are referenced internally using file descriptors so most likely you will get a result of (at least) 3 when you call open in any standard process.

And, according to man 2 open on my system,

... The argument mode specifies the permissions to use in case a new file is created. ...

In your specific example, it looks like you are creating the file in devilish mode ;)

Comments
This question has already been answered. Start a new discussion instead.