Starlink Project
Starlink User Note 121.6

P M Allan
A J Chipperfield
T Jenness
David S Berry

26th September 2019

Copyright © 2000 Council for the Central Laboratory of the Research Councils, 2006 Particle Physics and Astronomy Research Council

POSIX interface routines

Version 0.6-0

Programmer’s Manual


PSX is a FORTRAN subroutine library that allows programmers to use the functionality provided by the POSIX and X/OPEN libraries. The use of this library will enable programmers to make use of operating system facilities in a machine independent way.


1 Introduction
 1.1 Who should read this document?
 1.2 Overview
 1.3 What exactly is POSIX?
2 The PSX library
3 The Level of the Implementation
 3.1 Future Extensions
5 Compiling and Linking
6 References
A Examples
 A.1 Create a file with name that is specific to a user
 A.2 Get some virtual memory
B Include Files
C Alphabetical list of routines
D Classified list of routines
 D.1 Process Environment
 D.2 File System Support
 D.3 Language Specific Services for C (FORTRAN versions)
  D.3.1 Pseudo-Random Numbers
  D.3.2 Memory Management
  D.3.3 Date and Time
E Routine Descriptions
PSX_ACCESS – Check file accessibility
PSX_ASCTIME – Convert a time structure to a character string
PSX_CALLOC – Allocate space for several objects of specified type
PSX_CHDIR – Change current working directory
PSX_CTIME – Convert the calendar time to a character string
PSX_CUSERID – Get the username
PSX_FREE – Free virtual memory
PSX_GETCWD – Rename a file
PSX_GETEGID – Gets the effective group ID
PSX_GETENV – Translate an environment variable
PSX_GETEUID – Gets the effective user ID
PSX_GETGID – Gets the real group ID
PSX_GETPID – Gets the process ID
PSX_GETPPID – Gets the process ID of the parent process
PSX_GETUID – Gets the real user ID
PSX_GMTIME – Convert the value returned by PSX_TIME to individual GMT values
PSX_ISATTY – Determine if a file is a terminal
PSX_LOCALTIME – Convert the value returned by PSX_TIME to individual local time values
PSX_MALLOC – Allocate virtual memory
PSX_PUTENV – Set a new environment variable value
PSX_RAND – Generate a random number
PSX_REALLOC – Change the size of an allocated region of virtual memory
PSX_REMOVE – Remove a file or directory
PSX_RENAME – Rename a file
PSX_SRAND – Set the seed for the random number generator
PSX_STAT – Obtain information about a file
PSX_TIME – Get the current calendar time
PSX_TTYNAME – Get the name of the terminal
PSX_UNAME – Gets information about the host computer system

F Routines that have not been implemented
G Notes for System Programmers


[1]   IEEE Standard Portable Operating System Interface for Computer Environments (IEEE Std 1003.1-1988). Publ, Institute of Electrical and Electronic Engineers, Inc.

[2]   American National Standard for Information Systems – Programming Language – C (ANSI X3.159-1989). Publ, American National Standards Institute.

[3]   Portable Operating System Interface for Computer Environments, FORTRAN 77 Bindings (P1003.9 / Draft 5.0).