This file documents the Fortran 95 Posix bindings which can be used to interact with the OS from within Fortran.

Overview of Posix90
*******************

About Posix90
=============

Why Posix90? After all, you who read this document know most likely enough about mixed-language programming so you could write your own stubs. But such things tend to be quick hacks, and I wanted a clean solution: Here it is!

Portability
===========

At present, Posix90 is limited to gfortran and GNU/Linux. This might change if volunteers are found which port.

Linking against the Posix90 library
***********************************

It is assumed here that you build the library from source. This is necessary, as the .mod files (.mod files hold the information which data and which routines constitute a module. They are created as a module is compiled and are needed when this module is used elsewhere) which gfortran emits are still in a state of flux. It is too much work to provide them for all formats, compiling yourself is by far the best solution.

Place all .mod files in one directory, say /usr/local/include/f90 and place libposix90.a in another- say /usr/local/lib. You then need three compiler switches:

  * -I /usr/local/include/f90 , to tell the compiler where to search for .mod files

  * -lposix90, to tell the compiler to bind against libposix90.a

  * -L/usr/local/lib , to tell the compiler where to find libposix90.a

Note that there is a space after -I, but no space after -L.

Using the library
*****************

Calling and naming conventions
==============================

Wherever possible, the names of the original posix routines are used. char * arguments are mapped to character(len=*) (Be carefull with trailing spaces, use trim() or string(1:len) a lot). If the string is intent(out), an optional len argument is given to allow for trailing blanks. Int simply maps to integer. Small typedef'ed types like pid_t map to integer(pid_kind). More complex types like FILE map to type(FILE). Note that you should never pass derived types directly to C, as they are build alike their C pendants, but lack padding, makeing them assignment incompatible! Another issue here is the -fpackderived compiler switch.

All routines which possibly fail have an optional errno argument. If present, an error condition ( 0 == no error) is returned. If not present, an error message is printed if appropriate and execution stopped. All routines reset errno on entry. This behaviour is different from C, but makes it much easier to attribute an error to the offending routine.

Posix90 modules available
*************************

Module f90_unix_dir
===================

Parameters and Types
--------------------

     integer, parameter :: mode_kind

Integer kind used for file permissions.

Subroutines and Functions
-------------------------

     subroutine chdir(path, errno)
     character(len=*), intent(in) :: path
     integer, intent(out), optional :: errno

See man 2 chdir

     subroutine getcwd(path, lenpath, errno)
     character(len=*), intent(out) :: path
     integer, intent(out), optional :: lenpath, errno

See man 2 getcwd

     subroutine link(existing, new, errno)
     character(len=*), intent(in) :: existing, new
     integer, intent(out), optional :: errno

See man 2 link

     subroutine mkdir(path, mode, errno)
     character(len=*), intent(in) :: path
     integer(mode_kind), intent(in) :: mode
     integer, intent(out), optional :: errno

See man 2 mkdir

     subroutine mkfifo(path, mode, errno)
     character(len=*), intent(in) :: path
     integer(mode_kind), intent(in) :: mode
     integer, intent(out), optional :: errno

See man 2 mkfifo

     subroutine rmdir(path, errno)
     character(len=*), intent(in) :: path
     integer, intent(out), optional :: errno

See man 2 rmdir

     subroutine unlink(path, errno)
     character(len=*), intent(in) :: path
     integer, intent(out), optional :: errno

See man 2 unlink

Module f90_unix_dirent
======================

Parameters and Types
--------------------

     integer, parameter :: dir_kind

     type DIR
        integer(dir_kind):: dir
     end type DIR

Complex type handled by the routines in this section. You should not need to access its components directly.

Subroutines and Functions
-------------------------

     subroutine closedir(dirp, errno)
       type(dir), intent(inout) :: dirp
       integer, intent(out), optional :: errno

See man 3 closedir.

     subroutine opendir(dirname, dirp, errno)
       character(len=*), intent(in) :: dirname
       type(dir), intent(inout) :: dirp
       integer, intent(out), optional :: errno

See man 3 opendir.

     subroutine readdir(dirp, name, lenname, errno)
       type(dir), intent(inout) :: dirp
       character(len=*), intent(out) :: name
       integer, intent(out) :: lenname
       integer, intent(out), optional :: errno

See man 3 readdir. The lenname argument is needed in case of trailing blanks in name.

     subroutine rewinddir(dirp, errno)
       type(dir), intent(inout) :: dirp
       integer, intent(out), optional :: errno

See man 3 rewinddir.

Module f90_unix_env
===================

Parameters and Types
--------------------

     integer, parameter :: CLOCK_KIND
     integer, parameter :: LONG_KIND
     integer, parameter :: GID_KIND
     integer, parameter :: UID_KIND
     integer, parameter :: PID_KIND
     integer, parameter :: SIZET_KIND

Integer kind parameters for various data types.

     integer, parameter :: NULL

     integer, parameter :: L_CTERMID

Max. length of the result of ctermid().

     integer, parameter :: SC_ARG_MAX
     integer, parameter :: SC_CHILD_MAX
     integer, parameter :: SC_HOST_NAME_MAX
     integer, parameter :: SC_LOGIN_NAME_MAX
     integer, parameter :: SC_CLK_TCK
     integer, parameter :: SC_OPEN_MAX
     integer, parameter :: SC_PAGESIZE
     integer, parameter :: SC_RE_DUP_MAX
     integer, parameter :: SC_STREAM_MAX
     integer, parameter :: SC_SYMLOOP_MAX
     integer, parameter :: SC_TTY_NAME_MAX
     integer, parameter :: SC_TZNAME_MAX
     integer, parameter :: SC_VERSION

Possible values for the name argument to sysconf().

     type tms
        sequence
        integer(clock_kind):: utime, stime,cutime,cstime
     end type tms

Structure used in times(). See man 2 times.

     type utsname
        sequence
        character(len=80):: sysname, nodename, release, version, machine
     end type utsname

Structure used in uname(). See man 2 uname.

Subroutines and Functions
-------------------------

     integer(kind=clock_kind) function clk_tck()

Returns the clock ticks per second.

     character(len=L_CTERMID) function ctermid(len)
       integer, intent(out), optional :: len

     subroutine getarg2(k, arg, lenarg, errno)
       integer, intent(in) :: K
       character(len=*), intent(out), optional :: arg
       integer, intent(out), optional :: lenarg, errno

This routine is called getarg2 to avoid a name clash with the build-in getarg. Note that lenarg is at present always len_trim(arg) .

     integer(GID_KIND) function getegid()

     subroutine getenv2(name, value, lenvalue, errno)
       character(len=*), intent(in) :: name
       character(len=*), intent(out), optional :: value
       integer, intent(out), optional :: lenvalue, errno

This routine is called getenv2 to avoid a name clash with the build-in getenv. Note that lenvalue is at present always len_trim(value) .

     integer(uid_kind) function geteuid()
       integer(uid_kind),external::c_geteuid
       geteuid = c_geteuid()

     integer(gid_kind) function getgid()

     subroutine getgroups(grouplist, ngroups, errno)
       integer(gid_kind), optional :: grouplist(:)
       integer, optional, intent(out) :: ngroups, errno

     subroutine gethostname(name, lenname, errno)
       character(len=*), optional, intent(out) :: name
       integer, optional, intent(out) :: lenname, errno

     subroutine getlogin(name, lenname, errno)
       character(len=*), optional, intent(out) :: name
       integer, optional, intent(out) :: lenname, errno

     integer(PID_KIND) function getpgrp()

     integer(PID_KIND) function getppid()

     integer(UID_KIND) function getuid()

     subroutine setgid(gid, errno)
         integer(GID_KIND), intent(in) :: gid
         integer, intent(out), optional :: errno

     subroutine setpgid(gid, pgid, errno)
       integer(GID_KIND), intent(in) :: gid, pgid
       integer, intent(out), optional :: errno

     subroutine setsid(errno)
       integer, intent(out), optional :: errno

     subroutine setuid(gid, errno)
       integer(UID_KIND), intent(in) :: gid
       integer, intent(out), optional :: errno

     subroutine sysconf(name, val,errno)
         integer, intent(in) :: name
         integer(long_kind), intent(out) :: val
         integer, intent(out), optional :: errno

     integer(TIME_KIND) function time(errno)
       integer, optional, intent(out) :: errno
       integer(TIME_KIND), external :: c_time

     integer(CLOCK_KIND) function times(buffer, errno)
         type(tms) :: buffer
         integer, optional, intent(out) :: errno

     subroutine uname(name, errno)
       type(utsname), intent(out) :: name
       integer, optional, intent(out) :: errno

Module f90_unix_errno
=====================

Parameters and Types
--------------------

     integer, parameter :: E2BIG
     integer, parameter :: EACCES
     integer, parameter :: EAGAIN
     integer, parameter :: EBADF
     integer, parameter :: EBUSY
     integer, parameter :: ECHILD
     integer, parameter :: EDEADLK
     integer, parameter :: EDOM
     integer, parameter :: EEXIST
     integer, parameter :: EFAULT
     integer, parameter :: EFBIG
     integer, parameter :: EINTR
     integer, parameter :: EINVAL
     integer, parameter :: EIO
     integer, parameter :: EISDIR
     integer, parameter :: EMFILE
     integer, parameter :: EMLINK
     integer, parameter :: ENAMETOOLONG
     integer, parameter :: ENFILE
     integer, parameter :: ENODEV
     integer, parameter :: ENOENT
     integer, parameter :: ENOEXEC
     integer, parameter :: ENOLCK
     integer, parameter :: ENOMEM
     integer, parameter :: ENOSPC
     integer, parameter :: ENOSYS
     integer, parameter :: ENOTDIR
     integer, parameter :: ENOTEMPTY
     integer, parameter :: ENOTTY
     integer, parameter :: ENXIO
     integer, parameter :: EPERM
     integer, parameter :: EPIPE
     integer, parameter :: ERANGE
     integer, parameter :: EROFS
     integer, parameter :: ESPIPE
     integer, parameter :: ESRCH
     integer, parameter :: EXDEV

Error codes known to the module. Their names match the C equivalents.

Subroutines and Functions
-------------------------

     character(len=80) function strerror(err, errno)
       integer, intent(in) :: err
       integer, intent(out), optional :: errno

See man 3 strerror.

     subroutine perror(str, errc)
       character(len=*), intent(in) :: str
       integer, intent(in), optional :: errc

See man 3 perror.

     integer function get_errno()

Get the value of errno.

     subroutine set_errno(errc)
       integer, intent(in), optional :: errc

Set the value of errno to errc or 0, if errc is missing.

Module f90_unix_file
====================

Parameters and Types
--------------------

     use f90_unix_tools, only : C0
     use f90_unix_dir, only : mode_kind
     use f90_unix_env, only : uid_kind, gid_kind
     use f90_unix_time, only : time_kind

Constants used from other modules.

     integer, parameter :: f_ok
     integer, parameter :: r_ok
     integer, parameter :: W_ok
     integer, parameter :: X_ok

Constants used for access.

     integer, parameter :: S_IRGRP
     integer, parameter :: S_IROTH
     integer, parameter :: S_IRUSR
     integer, parameter :: S_IRWXG
     integer, parameter :: S_IRWXO
     integer, parameter :: S_IRWXU
     integer, parameter :: S_ISGID
     integer, parameter :: S_ISUID
     integer, parameter :: S_IWGRP
     integer, parameter :: S_IWOTH
     integer, parameter :: S_IWUSR
     integer, parameter :: S_IXGRP
     integer, parameter :: S_IXOTH
     integer, parameter :: S_IXUSR

Constants used for chmod.

     integer, parameter :: dev_kind
     integer, parameter :: ino_kind
     integer, parameter :: off_kind
     integer, parameter :: nlink_kind

Various kinds used in stat_t

     type stat_t
        integer(dev_kind) ::     st_dev
        integer(ino_kind) ::     st_ino
        integer(mode_kind) ::    st_mode
        integer(nlink_kind) ::   st_nlink
        integer(uid_kind) ::     st_uid
        integer(gid_kind) ::     st_gid
        integer(dev_kind) ::     st_rdev
        integer(off_kind) ::     st_size
        integer(time_kind) ::    st_atime
        integer(time_kind) ::    st_mtime
        integer(time_kind) ::    st_ctime
     end type stat_t

Type returned from stat. See man 2 stat for a field description.

     type utimbuf
        integer(time_kind) :: actime, modtime
     end type utimbuf

Subroutines and Functions
-------------------------

     subroutine access(path, amode, errno)
       character(len=*), intent(in) :: path
       integer, intent(in) :: amode
       integer, intent(out) :: errno

See man 2 access. Use of this function can often be replaced by iostat().

     subroutine chmod(path, mode, errno)
       character(len=*), intent(in) :: path
       integer(mode_kind), intent(in) :: mode
       integer, optional, intent(out) :: errno

See man 2 chmod.

     subroutine chown(path, owner, group, errno)
       character(len=*), intent(in) :: path
       integer(UID_KIND), intent(in) :: owner
       integer(GID_KIND), intent(in) :: group
       integer, optional, intent(out) :: errno

See man 2 chown

     subroutine stat(path, buf, errno)
       character(len=*), intent(in) :: path
       type(stat_t), intent(out) :: buf
       integer, optional, intent(out) :: errno

See man 2 stat.

Module f90_unix_io
==================

Parameters and Types
--------------------

     use f90_unix_errno
     use f90_unix_env, only : sizet_kind, NULL
     use f90_unix_tools, only : C0

Constants used in this module.

     integer, parameter :: EOF=-1

Definition of EOF

     integer, parameter :: FILE_KIND
     integer, parameter :: LONG_KIND

Kinds used in this module.

     integer, parameter :: SEEK_SET
     integer, parameter :: SEEK_CUR
     integer, parameter :: SEEK_END

Constants used for fseek.

     integer, parameter :: double

kind of 1.D0.

     type FILE
        integer(file_kind) :: fp
     end type FILE

Definition of FILE. There is no need to access fp directly.

     interface fread
        module procedure fread_str, fread_str_array
        module procedure fread_real, fread_real_array
        module procedure fread_double, fread_double_array
        module procedure fread_int, fread_int_array
     end interface

Interface for fread.

     interface fwrite
        module procedure fwrite_str, fwrite_str_array
        module procedure fwrite_real, fwrite_real_array
        module procedure fwrite_double, fwrite_double_array
        module procedure fwrite_int, fwrite_int_array
     end interface

Interface for fwrite.

     interface associated
        module procedure fassociated
     end interface

Function to do a fp!=NULL equivalent.

Subroutines and Functions
-------------------------

     logical function feof(stream, errno)
       type(FILE), intent(in) :: stream
       integer, intent(out), optional :: errno
       logical, external :: c_feof

Determine if stream is at eof. See man 3 feof.

     subroutine rewind(stream, errno)
       type(FILE), intent(inout) :: stream
       integer, intent(out), optional :: errno

Rewind a stream. See man 3 rewind.

     subroutine fseek(stream, offset, whence, errno)
       type(FILE), intent(inout) :: stream
       integer(long_kind), intent(in) :: offset
       integer, intent(in), optional :: whence
       integer, intent(out), optional :: errno

Seek a stream at a position. See man 3 fseek

     integer(long_kind) function ftell(stream, errno)
       type(FILE), intent(inout) :: stream
       integer, intent(out), optional :: errno

Get stream position. See man 3 ftell.

     logical function fassociated(fp)
       type(FILE), intent(in) :: fp

Check that a stream is non-NULL.

     type(FILE) function fopen(path, mode, errno)
       character(len=*), intent(in) :: path, mode
       integer, intent(out), optional :: errno

Open a stream. Use associated(FILE) to check the result is non-NULL. See man 3 fopen.

     subroutine fclose(fp, errno)
       type(FILE), intent(inout) :: fp
       integer, intent(out), optional :: errno

Close a stream. See man 3 fclose.

     type(FILE) function popen(command, mode, errno)
       character(len=*), intent(in) :: command, mode
       integer, intent(out), optional :: errno

Open a pipe to a command. See man 3 popen. Streams opened with popen must be pclosed.

     subroutine pclose(fp, errno)
       type(FILE), intent(inout) :: fp
       integer, intent(out), optional :: errno

Close a stream opened with popen. See man 3 pclose.

     integer(sizet_kind) function fread_str(str, length, fp, errno)
       character(len=*), intent(out) :: str
       integer(sizet_kind), intent(in) :: length
       type(FILE), intent(inout) :: fp
       integer, intent(out), optional :: errno

One form of the fread() interface.

     integer(sizet_kind) function fread_str_array(str, length, fp, errno)
       character(len=*), intent(out) :: str(:)
       integer(sizet_kind), intent(in) :: length
       type(FILE), intent(inout) :: fp
       integer, intent(out), optional :: errno

One form of the fread() interface.

     integer(sizet_kind) function fread_real(r, fp, errno)
       real, intent(out) :: r
       type(FILE), intent(inout) :: fp
       integer, intent(out), optional :: errno

One form of the fread() interface.

     integer(sizet_kind) function fread_real_array(r, fp, errno)
       real, intent(out) :: r(:)
       type(FILE), intent(inout) :: fp
       integer, intent(out), optional :: errno

One form of the fread() interface.

     integer(sizet_kind) function fread_double(d, fp, errno)
       real(double), intent(out) :: d
       type(FILE), intent(inout) :: fp
       integer, intent(out), optional :: errno

One form of the fread() interface.

     integer(sizet_kind) function fread_double_array(d, fp, errno)
       real(double), intent(out) :: d(:)
       type(FILE), intent(inout) :: fp
       integer, intent(out), optional :: errno

One form of the fread() interface.

     integer(sizet_kind) function fread_int(i, fp, errno)
       integer, intent(out) :: i
       type(FILE), intent(inout) :: fp
       integer, intent(out), optional :: errno

One form of the fread() interface.

     integer(sizet_kind) function fread_int_array(i, fp, errno)
       integer, intent(out) :: i(:)
       type(FILE), intent(inout) :: fp
       integer, intent(out), optional :: errno

One form of the fread() interface.

     integer(sizet_kind) function fwrite_str(str, length, fp, errno)
       character(len=*), intent(in) :: str
       integer(sizet_kind), intent(in) :: length
       type(FILE), intent(inout) :: fp
       integer, intent(out), optional :: errno

One form of the fwrite() interface.

     integer(sizet_kind) function fwrite_str_array(str, length, fp, errno)
       character(len=*), intent(in) :: str(:)
       integer(sizet_kind), intent(in) :: length
       type(FILE), intent(inout) :: fp
       integer, intent(out), optional :: errno

One form of the fwrite() interface.

     integer(sizet_kind) function fwrite_real(r, fp, errno)
       real, intent(in) :: r
       type(FILE), intent(inout) :: fp
       integer, intent(out), optional :: errno

One form of the fwrite() interface.

     integer(sizet_kind) function fwrite_real_array(r, fp, errno)
       real, intent(in) :: r(:)
       type(FILE), intent(inout) :: fp
       integer, intent(out), optional :: errno

One form of the fwrite() interface.

     integer(sizet_kind) function fwrite_double(r, fp, errno)
       real(double), intent(in) :: r
       type(FILE), intent(inout) :: fp
       integer, intent(out), optional :: errno

One form of the fwrite() interface.

     integer(sizet_kind) function fwrite_double_array(r, fp, errno)
       real(double), intent(in) :: r(:)
       type(FILE), intent(inout) :: fp
       integer, intent(out), optional :: errno

One form of the fwrite() interface.

     integer(sizet_kind) function fwrite_int(i, fp, errno)
       integer, intent(in) :: i
       type(FILE), intent(inout) :: fp
       integer, intent(out), optional :: errno

One form of the fwrite() interface.

     integer(sizet_kind) function fwrite_int_array(i, fp, errno)
       integer, intent(in) :: i(:)
       type(FILE), intent(inout) :: fp
       integer, intent(out), optional :: errno

One form of the fwrite() interface.

     subroutine fgets(str, strlen, fp, errno)
       character(len=*), intent(inout) :: str
       integer, intent(out) :: strlen
       type(FILE), intent(in) :: fp
       integer, intent(out), optional :: errno

See man 3 fgets.

     subroutine fputs(str, fp, errno)
       character(len=*), intent(in) :: str
       type(FILE):: fp
       integer, intent(out), optional :: errno

See man 3 fputs.

     type(FILE) function stdin()

Get stream stdin.

     type(FILE) function stdout()

Get stream stdout.

     type(FILE) function stderr()

Get stream stderr.

Module f90_unix_proc
====================

Module f90_unix_regexp
======================

Parameters and Types
--------------------

     integer, parameter :: REG_EXTENDED
     integer, parameter :: REG_ICASE
     integer, parameter :: REG_NOSUB
     integer, parameter :: REG_NEWLINE
     integer, parameter :: REG_NOTBOL
     integer, parameter :: REG_NOTEOL

Flags for regcomp and regexec. See man 3 regcomp

     integer, parameter :: REGEX_KIND
     integer, parameter :: REGMATCH_KIND
     integer, parameter :: REGOFF_KIND

Kinds used in the module. You should not need to use these direcly.

     type regex_t
        integer(regex_kind) :: rp
     end type regex_t

Type used to hold compiled regular expressions. You should not need to access its components directly.

     type regmatch_t
        integer(regoff_kind) :: rm_so, rm_eo
     end type regmatch_t

Type used to hold indices of matches. Note that these indices are adjusted to fortran numbering.

Subroutines and Functions
-------------------------

     subroutine regcomp(preg, regex, cflags, errc)
       type(regex_t) :: preg
       character(len=*), intent(in) :: regex
       integer, intent(in) :: cflags
       integer, intent(out), optional :: errc

See man 3 regcomp. Missing errc argument aborts on error.

     subroutine regexec(preg, string, pmatch, eflags, errc)
       type(regex_t), intent(in) :: preg
       character(len=*), intent(in) :: string
       type(regmatch_t) :: pmatch(:)
       integer, intent(in) :: eflags
       integer, intent(out), optional :: errc

See man 3 regexec. Note that the offsets in pmatch are adjusted to fortran conventions, aka the first char has index 1, not 0. Missing errc argument aborts on error. No match is considered an error.

     subroutine regerror(e, preg, msg)
       integer, intent(in) :: e
       type(regex_t), intent(in) :: preg
       character(len=*), intent(out) :: msg

See man 3 regerror.

     subroutine regfree(preg)
       type(regex_t), intent(in) :: preg

See man 3 regfree.

Module f90_unix_signal
======================

Introduction to fortran signal handling
---------------------------------------

Signal handling in Fortran faces an obstacle: The system calls the signal handler passing it an integer, whereas fortran expects a pointer to an integer. The library adresses this problem by installing a wrapper instead which accepts an integer and calls the fortran signal handler passing it a pointer to an integer. This is completly transparent to the user, except fot the special case where the signal handler is written in C. In this case, the SA_NOWRAPPER flag must be used which prevents installation of the wrapper. Note that sigaction passes back (in oldaction) the actual handler, not the wrapper. The SA_NOWRAPPER flag is automatically set if an action requires no wrapper.

Parameters and Types
--------------------

     integer, parameter :: funcp_kind

Integer kind to hold a function adress

     integer, parameter :: SIG_IGN
     integer, parameter :: SIG_DFL

Action codes to ignore a signal or use the default action.

     integer, parameter :: SIGHUP
     integer, parameter :: SIGINT
     integer, parameter :: SIGQUIT
     integer, parameter :: SIGILL
     integer, parameter :: SIGTRAP
     integer, parameter :: SIGABRT
     integer, parameter :: SIGIOT
     integer, parameter :: SIGBUS
     integer, parameter :: SIGFPE
     integer, parameter :: SIGKILL
     integer, parameter :: SIGUSR1
     integer, parameter :: SIGSEGV
     integer, parameter :: SIGUSR2
     integer, parameter :: SIGPIPE
     integer, parameter :: SIGALRM
     integer, parameter :: SIGTERM
     integer, parameter :: SIGSTKFLT
     integer, parameter :: SIGCLD
     integer, parameter :: SIGCHLD
     integer, parameter :: SIGCONT
     integer, parameter :: SIGSTOP
     integer, parameter :: SIGTSTP
     integer, parameter :: SIGTTIN
     integer, parameter :: SIGTTOU
     integer, parameter :: SIGURG
     integer, parameter :: SIGXCPU
     integer, parameter :: SIGXFSZ
     integer, parameter :: SIGVTALRM
     integer, parameter :: SIGPROF
     integer, parameter :: SIGWINCH
     integer, parameter :: SIGPOLL
     integer, parameter :: SIGIO
     integer, parameter :: SIGPWR
     integer, parameter :: SIGSYS
     integer, parameter :: SIGUNUSED
     integer, parameter :: NSIG

Signal codes. See man 7 signal

     integer, parameter :: SA_NOCLDSTOP
     integer, parameter :: SA_NOCLDWAIT
     integer, parameter :: SA_RESETHAND
     integer, parameter :: SA_ONSTACK
     integer, parameter :: SA_RESTART
     integer, parameter :: SA_NODEFER
     integer, parameter :: SA_NOWRAPPER
     integer, parameter :: SIG_BLOCK
     integer, parameter :: SIG_UNBLOCK
     integer, parameter :: SIG_SETMASK

Flags and other constants for sigaction.

Note that SA_SIGINFO is intentionally undefined- it cannot be used from within posix90.

     type sigset_type
       character(len=128) :: sigset
     end type

Type used to hold signal sets. See man 3 sigsetops.

     type sigaction_type
        integer(funcp_kind) :: sa_handler
        type(sigset_type) :: sa_mask
        integer :: sa_flags
     end type sigaction_type

Type to hold signal actions. Constructed using sigaction_compile. See sigaction.

     interface sigaction_compile
        module procedure sigaction_compile_handler
        module procedure sigaction_compile_integer
     end interface

Interface to construct a sigaction_type.

     type(sigaction_type) function sigaction_compile_handler(handler, mask, flags, errno)
       interface
          subroutine handler(sig)
            integer, intent(in) :: sig
          end subroutine handler
       end interface
       type(sigset_type), intent(in), optional :: mask
       integer, intent(in), optional :: flags
       integer, intent(out), optional :: errno

Construct a sigaction_type. mask defaults to sigemptyset, flags to 0. Note the interface sigaction_compile; this routine should not be called directly.

     type(sigaction_type) function sigaction_compile_integer(action_code, mask, flags, errno)
       integer, intent(in) :: action_code
       type(sigset_type), intent(in), optional :: mask
       integer, intent(in), optional :: flags
       integer, intent(out), optional :: errno

Construct a sigaction_type like action = sigaction_compile(SIG_IGN). Note the interface sigaction_compile. Errno EINVAL is set if action_code is neither SIG_IGN nor SIG_DFL.

     subroutine sigaction(signum, action, oldaction, errno)
       integer :: signum
       type(sigaction_type), intent(in), optional :: action
       type(sigaction_type), intent(out), optional :: oldaction
       integer, intent(out), optional :: errno

See man 2 sigaction.

     subroutine sigemptyset(set)
       type(sigset_type), intent(in):: set

See man 3 sigsetops.

     subroutine sigfillset(set)
       type(sigset_type), intent(in):: set

See man 3 sigsetops.

     subroutine sigaddset(set, sig1, sig2, sig3, sig4, sig5, sig6, sig7, sig8)
       type(sigset_type), intent(in):: set
       integer, intent(in) :: sig1
       integer, intent(in), optional :: sig2, sig3, sig4, sig5, sig6, sig7, sig8

See man 3 sigsetops.

     subroutine sigdelset(set, sig1, sig2, sig3, sig4, sig5, sig6, sig7, sig8)
       type(sigset_type), intent(in):: set
       integer, intent(in) :: sig1
       integer, intent(in), optional :: sig2, sig3, sig4, sig5, sig6, sig7, sig8

See man 3 sigsetops.

     logical function sigismember(set, sig)
       type(sigset_type), intent(in):: set
       integer, intent(in) :: sig

See man 3 sigsetops.

     subroutine kill(pid, sig, errno)
       integer(pid_kind), intent(in) :: pid
       integer, intent(in) :: sig
       integer, intent(out), optional :: errno

See man 2 kill.

     subroutine raise(sig,errno)
       integer, intent(in) :: sig
       integer, intent(out), optional :: errno

See man 3 raise.

Module f90_unix_time
====================

Parameters and Types
--------------------

     integer, parameter :: TIME_KIND

integer kind equivalent to C time_t.

Subroutines and Functions
-------------------------

     character(len=30) function ctime(time)
       integer(time_kind), intent(in) :: time

See man 3 ctime.

     [file gpl.texi not included]