posix module reference
Interface to the libc POSIX API
Data Types
Container for file metadata from stat |
|
Container for the jump point buffer created by setjmp(). |
|
Container for the jump point buffer (with signals) created by sigsetjmp() |
Procedure Interfaces
C interface to POSIX chmod() Users should use the Fortran-defined chmod() function. |
|
C interface to POSIX mkdir() Users should use the Fortran-defined mkdir() function. |
|
C interface to POSIX stat() Users should use the Fortran-defined stat() function. |
|
C interface to POSIX signal() Users should use the Fortran-defined signal() function. |
|
C interface to POSIX kill() Users should use the Fortran-defined kill() function. |
|
C interface to POSIX getpid() Users should use the Fortran-defined getpid() function. |
|
C interface to POSIX getppid() Users should use the Fortran-defined getppid() function. |
|
C interface to POSIX sleep() Users should use the Fortran-defined sleep() function. |
|
Save the current program execution state to env. |
|
Save the current execution and ,optionally, the signal state to env. |
|
C interface to POSIX longjmp() Users should use the Fortran-defined longjmp() function. |
|
C interface to POSIX siglongjmp() Users should use the Fortran-defined siglongjmp() function. |
Functions/Subroutines
Change mode of a file |
|
Create a file directory |
|
Get file status |
|
Create a signal handler handle to be called when sig is detected. |
|
Send signal sig to process pid. |
|
Get the ID of the current process. |
|
Get the ID of the parent process of the current process. |
|
Force the process to a sleep state for seconds seconds. |
|
Restore program to state saved by env, and return the value val. |
|
Restore program to state saved by env, and return the value val. |
|
Placeholder function for a missing or unconfigured setjmp |
|
Placeholder function for a missing or unconfigured longjmp |
|
Placeholder function for a missing or unconfigured sigsetjmp |
|
Placeholder function for a missing or unconfigured siglongjmp |
Type Documentation
- type, bind(c) :: stat_buf
Container for file metadata from stat
NOTE: This is currently just a placeholder containing fields, such as size, uid, mode, etc. A readable Fortran type may be used in the future.
- Parameters
state
Byte array containing file metadata
- type, bind(c) :: jmp_buf
Container for the jump point buffer created by setjmp().
The buffer typically contains the current register values, stack pointers, and any information required to restore the process state.
- Parameters
state
Unstructured array of bytes used to store the process state
- type, bind(c) :: sigjmp_buf
Container for the jump point buffer (with signals) created by sigsetjmp()
In addition to the content stored by jmp_buf, it also stores signal state.
- Parameters
state
Unstructured array of bytes used to store the process state
Procedure Interface Documentation
- function chmod_posix(path, mode) result(rc) bind(c, name="chmod")
C interface to POSIX chmod() Users should use the Fortran-defined chmod() function.
- Parameters
path [in]
Zero-delimited file path
mode [in]
File permission to be assigned to file.
rc
Function return code
- function mkdir_posix(path, mode) result(rc) bind(c, name="mkdir")
C interface to POSIX mkdir() Users should use the Fortran-defined mkdir() function.
- Parameters
path [in]
Zero-delimited file path
mode [in]
File permission to be assigned to file.
rc
Function return code
- function stat_posix(path, buf) result(rc) bind(c, name="stat")
C interface to POSIX stat() Users should use the Fortran-defined stat() function.
- Parameters
path [in]
Pathname of a POSIX file
buf [inout]
Information describing the file if it exists
rc
Function return code
- function signal_posix(sig, func) result(handle) bind(c, name="signal")
C interface to POSIX signal() Users should use the Fortran-defined signal() function.
- Parameters
sig [in]
Signal to be configured
func [in]
Function handle to be called when sig is raised
handle
Prior handle for sig to be replaced by func
- function kill_posix(pid, sig) result(rc) bind(c, name="kill")
C interface to POSIX kill() Users should use the Fortran-defined kill() function.
- Parameters
pid [in]
Process ID which is to receive the signal
sig [in]
Signal to be sent to the process
rc
Function return code
- function getpid_posix() result(pid) bind(c, name="getpid")
C interface to POSIX getpid() Users should use the Fortran-defined getpid() function.
- Parameters
pid
Process ID of the current process.
- function getppid_posix() result(pid) bind(c, name="getppid")
C interface to POSIX getppid() Users should use the Fortran-defined getppid() function.
- Parameters
pid
Process ID of the parent process to the current process.
- function sleep_posix(seconds) result(rc) bind(c, name="sleep")
C interface to POSIX sleep() Users should use the Fortran-defined sleep() function.
- Parameters
seconds [in]
Number of real-time seconds which the thread should sleep
rc
Function return code
- function setjmp(env) result(rc) bind(c, name="setjmp_missing")
Save the current program execution state to env.
This function creates a snapshot of the process state to env, which can be restored by calling longjmp. When setjmp is called, the function returns 0. When longjmp is later called, the program is restored to the point where setjmp was called, except it now returns a value (rc) as specified by longjmp.
- Parameters
env [in]
Current process state
rc
Function return code; set to 0 if setjmp() was called, otherwise specified by the corresponding longjmp() call.
- function sigsetjmp(env, savesigs) result(rc) bind(c, name="sigsetjmp_missing")
Save the current execution and ,optionally, the signal state to env.
This function creates a snapshot of the process state to env, which can be restored by calling longjmp. When setjmp is called, the function returns 0. When longjmp is later called, the program is restored to the point where setjmp was called, except it now returns a value (rc) as specified by longjmp.
If savesigs is set to a nonzero value, then the signal state is included in the program state.
- Parameters
env [in]
Current process state
savesigs [in]
Flag to enable signal state when set to a nonzero value
rc
Function return code; set to 0 if sigsetjmp() was called, otherwise specified by the corresponding siglongjmp() call.
- subroutine longjmp_posix(env, val) bind(c, name="longjmp_missing")
C interface to POSIX longjmp() Users should use the Fortran-defined longjmp() function.
- Parameters
env [in]
Process state to restore
val [in]
Return code sent to setjmp()
- subroutine siglongjmp_posix(env, val) bind(c, name="siglongjmp_missing")
C interface to POSIX siglongjmp() Users should use the Fortran-defined siglongjmp() function.
- Parameters
env [in]
Process state to restore
val [in]
Return code sent to sigsetjmp()
Functions/Subroutine Documentation
- function chmod(path, mode) result(rc)
Change mode of a file
This changes the file permission of file path to mode following POSIX conventions. If successful, it returns zero. Otherwise, it returns -1.
- function mkdir(path, mode) result(rc)
Create a file directory
This creates a new directory named path with permissons set by mode. If successful, it returns zero. Otherwise, it returns -1.
- function stat(path, buf) result(rc)
Get file status
This obtains information about the named file and writes it to buf. If found, it returns zero. Otherwise, it returns -1.
- Parameters
path [in]
Pathname of file to be inspected
buf [out]
Buffer containing information about the file if it exists
rc
Function return code
- function signal(sig, func) result(handle)
Create a signal handler handle to be called when sig is detected.
If successful, the previous handler for sig is returned. Otherwise, SIG_ERR is returned.
- function kill(pid, sig) result(rc)
Send signal sig to process pid.
If successful, this function returns 0. Otherwise, it returns -1.
- function getpid() result(pid)
Get the ID of the current process.
- function getppid() result(pid)
Get the ID of the parent process of the current process.
- function sleep(seconds) result(rc)
Force the process to a sleep state for seconds seconds.
The sleep state may be interrupted by a signal. If it sleeps for the entire duration, then it returns 0. Otherwise, it returns the number of seconds remaining at the point of interruption.
- subroutine longjmp(env, val)
Restore program to state saved by env, and return the value val.
This "nonlocal goto" alters program execution to the state stored in env produced by a prior execution of setjmp. Program execution is moved back to this setjmp, except the function will now return val.
- subroutine siglongjmp(env, val)
Restore program to state saved by env, and return the value val.
This "nonlocal goto" alters program execution to the state stored in env produced by a prior execution of setjmp. Program execution is moved back to this setjmp, except the function will now return val.
siglongjmp behaves in the same manner as longjmp, but also provides predictable handling of the signal state.
- function setjmp_missing(env) result(rc) bind(c)
Placeholder function for a missing or unconfigured setjmp
- Parameters
env [in]
Current process state (unused)
rc
Function return code (unused)
- subroutine longjmp_missing(env, val) bind(c)
Placeholder function for a missing or unconfigured longjmp
- Parameters
env [in]
Current process state (unused)
val [in]
Enable signal state flag (unused)
- function sigsetjmp_missing(env, savesigs) result(rc) bind(c)
Placeholder function for a missing or unconfigured sigsetjmp
- Parameters
env [in]
Current process state (unused)
savesigs [in]
Enable signal state flag (unused)
rc
Function return code (unused)
- subroutine siglongjmp_missing(env, val) bind(c)
Placeholder function for a missing or unconfigured siglongjmp
- Parameters
env [in]
Current process state (unused)
val [in]
Enable signal state flag (unused)