PreviousUpNext

15.3.528  src/lib/std/src/psx/posix-process.api

## posix-process.api
#
# Api for POSIX 1003.1 process submodule
#
# See also:
#     src/lib/std/src/winix/winix-process--premicrothread.api
#     src/lib/std/src/psx/posix-process.api

# Compiled by:
#     src/lib/std/src/standard-core.sublib


# Compiled by:
#     src/lib/std/src/standard-core.sublib






###         "I wanted to have virtual memory, at least
###          as it's coupled with file systems.
###
###                               -- Ken Thompson 



###         "The world is changing:
###          I feel it in the water,
###          I feel it in the earth,
###          and I smell it in the air."
###
###                  -- Treebeard
###
###                   [J.R.R. Tolkein, "Lord of the Rings"]



stipulate
    package hi  =  host_int;                                            # host_int              is from   src/lib/std/src/psx/host-int.pkg
    package hu  =  host_unt;                                            # host_unt              is from   src/lib/std/types-only/bind-largest32.pkg
    package sig =  interprocess_signals;                                # interprocess_signals  is from   src/lib/std/src/nj/interprocess-signals.pkg
    package tim =  time;                                                # time                  is from   src/lib/std/types-only/basis-time.pkg
    package u1b =  one_byte_unt;                                        # one_byte_unt          is from   src/lib/std/types-only/basis-structs.pkg
    package wt  =  winix_types;                                         # winix_types           is from   src/lib/std/src/posix/winix-types.pkg
                                                                        # winix_types           is from   src/lib/std/src/win32/winix-types.pkg
herein

    api Posix_Process {
        #
        eqtype Process_Id;

        unt_to_pid:      hu::Unt -> Process_Id;
        pid_to_unt:      Process_Id -> hu::Unt;


        fork:  Void -> Null_Or( Process_Id );
            #
            # This is essentially the unix-level fork().
            # For a higher-level fork() see fork_process() in
            #
            #     src/lib/std/src/posix/spawn--premicrothread.api
            #     src/lib/std/src/posix/spawn--premicrothread.pkg

        exec:   (String, List( String )) -> X;
        exece:  (String, List( String ), List( String )) -> X;
        execp:  (String, List( String )) -> X;

        Waitpid_Arg
          = W_ANY_CHILD
          | W_CHILD  Process_Id
          | W_SAME_GROUP
          | W_GROUP  Process_Id
          ;

        Exit_Status
          = W_EXITED
          | W_EXITSTATUS  u1b::Unt
          | W_SIGNALED  sig::Signal
          | W_STOPPED   sig::Signal
          ;

        package w:  api {
                        include api Bit_Flags;          # Bit_Flags     is from   src/lib/std/src/bit-flags.api
                        #
                        untraced:  Flags;
                    };

        wait:                      Void -> (Process_Id, Exit_Status);
        #
        waitpid:                   (Waitpid_Arg, List( w::Flags )) ->          (Process_Id, Exit_Status);
        waitpid_without_blocking:  (Waitpid_Arg, List( w::Flags )) -> Null_Or( (Process_Id, Exit_Status) );

        exit:  u1b::Unt -> X;

        Killpid_Arg   = K_PROC  Process_Id
                      | K_GROUP Process_Id
                      | K_SAME_GROUP
                      ;

        kill:  (Killpid_Arg, sig::Signal) -> Void;

        alarm:  tim::Time -> tim::Time;
        pause:  Void -> Void;
        sleep:  tim::Time -> tim::Time;                                         # Sleeps only to a resolution of seconds:  You can sleep with sub-second resolution via winix__premicrothread::process::sleep or winix__premicrothread::io::poll.

osval:  String -> Int;


        #######################################################################
        # Below stuff is intended only for one-time use during
        # booting, to switch from direct to indirect syscalls:                  # For background see Note[1]            in   src/lib/std/src/unsafe/mythryl-callable-c-library-interface.pkg


             osval__syscall:    String -> hi::Int;
        set__osval__ref:      ({ lib_name: String, fun_name: String, io_call: (String -> hi::Int) } -> (String -> hi::Int)) -> Void;

             sysconf__syscall:    String -> hu::Unt;
        set__sysconf__ref:      ({ lib_name: String, fun_name: String, io_call: (String -> hu::Unt) } -> (String -> hu::Unt)) -> Void;

             waitpid__syscall:    (hi::Int, hu::Unt) -> (hi::Int, hi::Int, hi::Int);
        set__waitpid__ref:      ({ lib_name: String, fun_name: String, io_call: ((hi::Int, hu::Unt) -> (hi::Int, hi::Int, hi::Int)) } -> ((hi::Int, hu::Unt) -> (hi::Int, hi::Int, hi::Int))) -> Void;

             kill__syscall:    (hi::Int, hi::Int) -> Void;
        set__kill__ref:      ({ lib_name: String, fun_name: String, io_call: ((hi::Int, hi::Int) -> Void) } -> ((hi::Int, hi::Int) -> Void)) -> Void;
    };                                                                          #  Api Posix_Process 
end;


## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext