PreviousUpNext

15.3.581  src/lib/std/src/winix/winix-process–premicrothread.api

## winix-process--premicrothread.api
#
# The generic process control interface.
# A sub-api of api Winix__Premicrothread:
#
#     src/lib/std/src/winix/winix--premicrothread.api

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


# This API is implemented in:
#
#     src/lib/std/src/posix/winix-process--premicrothread.pkg

api Winix_Process__Premicrothread {
    #
    Status = Int;

    success:            Status;                         # 0             ### "Success is as dangerous as failure."   -- Lao-tzu
    failure:            Status;                         # 1

    successful:         Status -> Bool;

    bin_sh':            String -> Status;

                                                        # Used to have at_exit here, but dropped at-exit.pkg in favor of run-at--premicrothread.pkg.

    exit:               Status -> Void;                 # This is what you usually want.  Does   at::run_functions_scheduled_to_run  at::SHUTDOWN;   and then   exit_uncleanly()  (below).
    exit_uncleanly:     Status -> Void;                 # Calls C-level exit() fn via the exit() fn in src/lib/std/src/psx/posix-process.pkg

    exit_x:             Status -> X;
    exit_uncleanly_x:   Status -> X;
        #
        # These are identical to exit/exit_uncleanly except for the type.
        #
        # From a pedantic point of view exit/exit_uncleanly should be
        #     Status -> X
        # because they do not return, hence their result type
        # can be taken to be anything convenient.  
        #
        # From a practical point of view, the X return type is often more
        # trouble than it is worth, because every now and then these
        # calls get used in a context where the compiler cannot deduce
        # a good type for X, resulting in the compile aborting with an
        # error message.
        #     Beginners find this confusing rather than helpful,
        # so I've changed exit/exit_uncleanly to nominally return Void.
        #     I've also provided exit_x/exit_uncleanly_x because the more
        # advanced programmer will occasionally find them useful,
        # for example in constructs like
        # 
        #     case foo
        #         #
        #         this =>  f(x);
        #         _    =>  exit_x(0);           # Here it helps to have   exit_x(0)   automatically match the type of   f(x);
        #     esac;

    get_env:  String -> Null_Or( String );

    sleep:  Float -> Void;

    get_process_id: Void -> Int;

};


## 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