Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/f/fileno.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/f/fileno.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/f/fileno.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/f/fileno.html on line 8

fileno()

Return the file descriptor for a stream

Synopsis:

#include <stdio.h>

int fileno( FILE * stream );

Arguments:

stream
The stream whose file descriptor you want to find.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The fileno() function returns the file descriptor for the specified file stream. This file descriptor can be used in POSIX input/output calls anywhere the value returned by open() can be used.

To associate a stream with a file descriptor, call fdopen().


Note: In QNX Neutrino, the file descriptor is also the connection ID (coid) used by various Neutrino-specific functions.

The following symbolic values in <unistd.h> define the file descriptors associated with the C language stdin, stdout, and stderr streams:

STDIN_FILENO
Standard input file number, stdin (0)
STDOUT_FILENO
Standard output file number, stdout (1)
STDERR_FILENO
Standard error file number, stderr (2)

Returns:

A file descriptor, or -1 if an error occurs (errno is set).

Examples:

#include <stdlib.h>
#include <stdio.h>

int main( void )
{
    FILE *stream;

    stream = fopen( "file", "r" );
    if( stream != NULL ) {
        printf( "File number is %d.\n", fileno( stream ) );
        fclose( stream );
        
        return EXIT_SUCCESS;
    }
    
    return EXIT_FAILURE;
}

Produces output similar to:

File number is 7.

Classification:

POSIX 1003.1

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

errno, fdopen(), fopen(), open()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/f/fileno.html on line 189

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/f/fileno.html on line 189