I have to set the return values for open() in posix. How do I return the new file descriptor as it is said in the Linux man pages:RETURN VALUE open(), openat(), and creat() return the new file descriptor, or -1 if an error occurred (in which case, errno is set appropriately).Edit: Thanks goldilocks! I was not looking in the right direction. What I am doing is that I am correcting the return value of this system call. Apparently it returns something wrong.
open() return new file descriptor posix
posix;c++;system calls;error handling
To open a file, you use a construct like the following:int fd;if ((fd = open(path, flags)) < 0) {    /* An error occurred, the reason is in errno */    int _errno = errno; /* Save errno value */    fprintf(stderr, Failed opening file '%s': %s\n, path, strerror(_errno));    return;}/* The file was successfully opened */So, you have only one return value, which normally is the file descriptor. If it is -1, it indicates that an error has occurred. The error that occurred is stored in the errno variable (which you get by including errno.h into your source file).