### 4.26 `__fsetlocking`—set or query locking mode on FILE stream

Synopsis

    #include <stdio.h>
    #include <stdio_ext.h>
    int __fsetlocking(FILE *fp, int type);

Description
This function sets how the stdio functions handle locking of FILE fp. The following values describe type:

`FSETLOCKING_INTERNAL` is the default state, where stdio functions automatically lock and unlock the stream.

`FSETLOCKING_BYCALLER` means that automatic locking in stdio functions is disabled. Applications which set this take all responsibility for file locking themselves.

`FSETLOCKING_QUERY` returns the current locking mode without changing it.

Returns
`__fsetlocking` returns the current locking mode of fp.

Portability
This function originates from Solaris and is also provided by GNU libc.

No supporting OS subroutines are required.