PreviousUpNext

15.4.1138  src/lib/std/src/posix/threadkit-winix-process.pkg

## threadkit-winix-process.pkg

# Compiled by:
#     src/lib/std/standard.lib



# The generic process control interface.

stipulate
    package fat =  fate;                                                        # fate                          is from   src/lib/std/src/nj/fate.pkg
    package mop =  mailop;                                                      # mailop                        is from   src/lib/src/lib/thread-kit/src/core-thread-kit/mailop.pkg
    package ts  =  thread_scheduler;                                            # thread_scheduler              is from   src/lib/src/lib/thread-kit/src/core-thread-kit/thread-scheduler.pkg
    package pm  =  process_deathwatch;                                          # process_deathwatch            is from   src/lib/src/lib/thread-kit/src/process-deathwatch.pkg
    #                                                                           # winix                         is from   src/lib/std/winix.pkg
    package pcs =  winix::process;                                              # winix::process                is from   src/lib/std/src/posix/winix-process.pkg
    package psx =  posix_1003_1b;                                               # posix_1003_1b                 is from   src/lib/std/src/posix-1003.1b/posix-1003-1b.pkg
herein

    package   threadkit_winix_process
    : (weak)  Threadkit_Winix_Process                                           # Threadkit_Winix_Process       is from   src/lib/src/lib/thread-kit/src/winix/threadkit-winix-process.api
    {
        Status  =  pcs::Status;
        #
        success =  pcs::success;
        failure =  pcs::failure;

        # * NOTE: we probably need to disable timer signals here *  XXX BUGGO FIXME

        fun system' cmd
            =
            {   ts::stop_thread_scheduler_timer();                              # This can't be good! :-)
                #
                case (psx::fork ())
                    #
                    NULL    =>  psx::exec ("/bin/sh", ["sh", "-c", cmd]) psx::exit 0u127;
                    #
                    THE pid =>  {   ts::restart_thread_scheduler_timer();
                                    pid;
                                };
                esac;
            };

        fun system_mailop  cmd
            =
            {   pid =  system' cmd;
                #
                mailop =    {   ts::disable_thread_switching ();
                                #
                                pm::add_pid pid
                                before
                                    ts::reenable_thread_switching ();
                            };

                mop::wrap
                  (
                    mailop,
                    #   
                    fn psx::W_EXITED =>  pcs::success;
                       _             =>  pcs::failure;
                    end
                  );
            };

        system =  mop::do_mailop  o  system_mailop;

        fun at_exit _
            =
            raise exception  FAIL "winix::process::at_exit unimplemented";              # XXX BUGGO FIXME

        fun exit status      =  { ts::disable_thread_switching();   fat::resume_fate  *ts::shutdown_hook  (TRUE,  status); };
        fun terminate status =  { ts::disable_thread_switching();   fat::resume_fate  *ts::shutdown_hook  (FALSE, status); };

        get_env =  pcs::get_env;
    };
end;

## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2012,
## released under Gnu Public Licence version 3.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext