## winix-process.pkg
#
# The generic process control interface.
# Compiled by:
#
src/lib/std/standard.libstipulate
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 mps = microthread_preemptive_scheduler; # microthread_preemptive_scheduler is from
src/lib/src/lib/thread-kit/src/core-thread-kit/microthread-preemptive-scheduler.pkg package pm = process_deathwatch; # process_deathwatch is from
src/lib/src/lib/thread-kit/src/process-deathwatch.pkg # # winix__premicrothread is from
src/lib/std/winix--premicrothread.pkg package pcs = winix__premicrothread::process; # winix__premicrothread::process is from
src/lib/std/src/posix/winix-process--premicrothread.pkg package psx = posixlib; # posixlib is from
src/lib/std/src/psx/posixlib.pkgherein
package winix_process
: (weak) Winix_Process # Winix_Process is from
src/lib/src/lib/thread-kit/src/winix/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 bin_sh'' cmd
=
{ mps::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 => { mps::restart_thread_scheduler_timer();
pid;
};
esac;
};
fun bin_sh'_mailop cmd
=
{ pid = bin_sh'' cmd;
#
mailop = {
microthread_preemptive_scheduler::assert_not_in_uninterruptible_scope "bin_sh'_mailop";
log::uninterruptible_scope_mutex := 1;
#
pm::start_child_process_deathwatch pid
then
log::uninterruptible_scope_mutex := 0;
};
mop::if_then' # "mop::if_then'" is the plain name for mop::(==>).
(
mailop,
#
\\ psx::W_EXITED => pcs::success;
_ => pcs::failure;
end
);
};
bin_sh' = mop::block_until_mailop_fires o bin_sh'_mailop;
# fun at_exit _ # NB: These days we're anyhow trying to instead use the more general
src/lib/std/src/nj/run-at--premicrothread.pkg# =
# raise exception DIE "winix::process::at_exit unimplemented"; # XXX BUGGO FIXME
fun exit status = { log::uninterruptible_scope_mutex := 1; fat::switch_to_fate *mps::thread_scheduler_shutdown_hook (TRUE, status); }; #
fun exit_uncleanly status = { log::uninterruptible_scope_mutex := 1; fat::switch_to_fate *mps::thread_scheduler_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-2015,
## released per terms of SMLNJ-COPYRIGHT.