Search code examples
cunixprocessc-standard-library

Is popen standard C function?


Reading about the function popen.

It is in header stdio.h (standard header), it returns FILE* (standard IO struct, unlike Unix functions from unistd.h), but i can't find it on any C standard reference website.

So is it standard, or is it some kind of GCC extension? What is it?


Solution

  • From the man page you linked:

    CONFORMING TO         top
           POSIX.1-2001, POSIX.1-2008.
    
           The 'e' value for type is a Linux extension.
    

    It a function defined in POSIX standard. And the e value for type is a linux extension.

    Is popen standard C function?

    No. popen is not a standard C function, meaning it's not defined in C standard.

    So is it standard, or is it some kind of GCC extension? What is it?

    It is a standard POSIX function. It is not a GCC extension. It is a function.

    Then why it's in stdio.h and not in unistd.h or something?

    The popen declaration is visible after including stdio.h on POSIX compatible systems, because the POSIX standard says so. ( Why it's not posix/stdio.h or like sys/stdio.h it's mostly for historic reasons. Every system just uses stdio.h. )