dm_pipe Module

Module for basic subprocess management on Unix. Procedures with name postfix 2 are for bi-directional IPC, all other for uni-directional only.


Uses

  • module~~dm_pipe~~UsesGraph module~dm_pipe dm_pipe module~dm_error dm_error module~dm_pipe->module~dm_error module~dm_kind dm_kind module~dm_pipe->module~dm_kind unix unix module~dm_pipe->unix module~dm_error->module~dm_kind module~dm_ascii dm_ascii module~dm_error->module~dm_ascii iso_fortran_env iso_fortran_env module~dm_kind->iso_fortran_env

Used by

  • module~~dm_pipe~~UsedByGraph module~dm_pipe dm_pipe module~dm_plot dm_plot module~dm_plot->module~dm_pipe module~dmpack dmpack module~dmpack->module~dm_pipe module~dmpack->module~dm_plot module~dm_report dm_report module~dmpack->module~dm_report module~dm_report->module~dm_plot

Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: PIPE_RDONLY = 1

Read-only access.

integer, public, parameter :: PIPE_WRONLY = 2

Write-only access.


Derived Types

type, public ::  pipe_type

Opaque pipe type. Stores the C pointer of uni-directional pipe.


Functions

public function dm_pipe_connected(pipe) result(connected)

Returns .true. if pipe is connected.

Arguments

Type IntentOptional Attributes Name
type(pipe_type), intent(inout) :: pipe

Pipe type.

Return Value logical

public function dm_pipe_open(pipe, command, access) result(rc)

Opens a process by creating a pipe, forking, and invoking the shell. Access mode has to be either PIPE_RDONLY or PIPE_WRONLY.

Read more…

Arguments

Type IntentOptional Attributes Name
type(pipe_type), intent(inout) :: pipe

Pipe type.

character(len=*), intent(in) :: command

Name or path of binary to open.

integer, intent(in) :: access

Open pipe for reading or writing.

Return Value integer

public function dm_pipe_open2(stdin, stdout, stderr, command) result(rc)

Creates three anonymous pipes for bidirectional IPC (stdin, stdout, stderr).

Read more…

Arguments

Type IntentOptional Attributes Name
type(pipe_type), intent(out) :: stdin

Standard input handle.

type(pipe_type), intent(out) :: stdout

Standard output handle.

type(pipe_type), intent(out) :: stderr

Standard error handle.

character(len=*), intent(in) :: command

Program to invoke.

Return Value integer

public function dm_pipe_read(pipe, bytes) result(sz)

Reads from pipe to buffer bytes (binary) and returns number of bytes written to buffer.

Arguments

Type IntentOptional Attributes Name
type(pipe_type), intent(inout) :: pipe

Bi-directional pipe.

character(len=*), intent(inout), target :: bytes

Output buffer.

Return Value integer(kind=i8)

public function dm_pipe_write(pipe, str) result(rc)

Writes to pipe. Trims the string, adds new line and null-termination.

Read more…

Arguments

Type IntentOptional Attributes Name
type(pipe_type), intent(inout) :: pipe

Pipe type.

character(len=*), intent(in) :: str

String to write to the pipe.

Return Value integer

public function dm_pipe_write2(pipe, bytes) result(sz)

Writes to pipe (binary) and returns the number of bytes written.

Arguments

Type IntentOptional Attributes Name
type(pipe_type), intent(inout) :: pipe

Bi-directional pipe.

character(len=*), intent(in), target :: bytes

Bytes to write to the pipe.

Return Value integer(kind=i8)


Subroutines

public subroutine dm_pipe_close(pipe)

Closes pipe to process.

Arguments

Type IntentOptional Attributes Name
type(pipe_type), intent(inout) :: pipe

Pipe type.

public subroutine dm_pipe_close2(pipe)

Closes pipe to process (binary).

Arguments

Type IntentOptional Attributes Name
type(pipe_type), intent(inout) :: pipe

Pipe type.