Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > 1abfe597bc89458ccaa645cd148862bb > files > 679

ocaml-ocamlnet-doc-3.7.3-3.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<link rel="Start" href="index.html">
<link rel="previous" href="Rpc_xti_client.html">
<link rel="next" href="Shell.html">
<link rel="Up" href="index.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of class attributes" rel=Appendix href="index_attributes.html">
<link title="Index of class methods" rel=Appendix href="index_methods.html">
<link title="Index of classes" rel=Appendix href="index_classes.html">
<link title="Index of class types" rel=Appendix href="index_class_types.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Index of module types" rel=Appendix href="index_module_types.html">
<link title="Uq_gtk" rel="Chapter" href="Uq_gtk.html">
<link title="Equeue" rel="Chapter" href="Equeue.html">
<link title="Unixqueue" rel="Chapter" href="Unixqueue.html">
<link title="Unixqueue_pollset" rel="Chapter" href="Unixqueue_pollset.html">
<link title="Unixqueue_select" rel="Chapter" href="Unixqueue_select.html">
<link title="Uq_resolver" rel="Chapter" href="Uq_resolver.html">
<link title="Uq_engines" rel="Chapter" href="Uq_engines.html">
<link title="Uq_socks5" rel="Chapter" href="Uq_socks5.html">
<link title="Uq_io" rel="Chapter" href="Uq_io.html">
<link title="Uq_lwt" rel="Chapter" href="Uq_lwt.html">
<link title="Uq_libevent" rel="Chapter" href="Uq_libevent.html">
<link title="Uq_mt" rel="Chapter" href="Uq_mt.html">
<link title="Equeue_intro" rel="Chapter" href="Equeue_intro.html">
<link title="Equeue_howto" rel="Chapter" href="Equeue_howto.html">
<link title="Uq_ssl" rel="Chapter" href="Uq_ssl.html">
<link title="Https_client" rel="Chapter" href="Https_client.html">
<link title="Uq_tcl" rel="Chapter" href="Uq_tcl.html">
<link title="Netcamlbox" rel="Chapter" href="Netcamlbox.html">
<link title="Netcgi_apache" rel="Chapter" href="Netcgi_apache.html">
<link title="Netcgi_modtpl" rel="Chapter" href="Netcgi_modtpl.html">
<link title="Netcgi_common" rel="Chapter" href="Netcgi_common.html">
<link title="Netcgi" rel="Chapter" href="Netcgi.html">
<link title="Netcgi_ajp" rel="Chapter" href="Netcgi_ajp.html">
<link title="Netcgi_scgi" rel="Chapter" href="Netcgi_scgi.html">
<link title="Netcgi_cgi" rel="Chapter" href="Netcgi_cgi.html">
<link title="Netcgi_fcgi" rel="Chapter" href="Netcgi_fcgi.html">
<link title="Netcgi_dbi" rel="Chapter" href="Netcgi_dbi.html">
<link title="Netcgi1_compat" rel="Chapter" href="Netcgi1_compat.html">
<link title="Netcgi_test" rel="Chapter" href="Netcgi_test.html">
<link title="Netcgi_porting" rel="Chapter" href="Netcgi_porting.html">
<link title="Netcgi_plex" rel="Chapter" href="Netcgi_plex.html">
<link title="Http_client_conncache" rel="Chapter" href="Http_client_conncache.html">
<link title="Http_client" rel="Chapter" href="Http_client.html">
<link title="Telnet_client" rel="Chapter" href="Telnet_client.html">
<link title="Ftp_data_endpoint" rel="Chapter" href="Ftp_data_endpoint.html">
<link title="Ftp_client" rel="Chapter" href="Ftp_client.html">
<link title="Http_fs" rel="Chapter" href="Http_fs.html">
<link title="Ftp_fs" rel="Chapter" href="Ftp_fs.html">
<link title="Netclient_tut" rel="Chapter" href="Netclient_tut.html">
<link title="Netgssapi" rel="Chapter" href="Netgssapi.html">
<link title="Nethttpd_types" rel="Chapter" href="Nethttpd_types.html">
<link title="Nethttpd_kernel" rel="Chapter" href="Nethttpd_kernel.html">
<link title="Nethttpd_reactor" rel="Chapter" href="Nethttpd_reactor.html">
<link title="Nethttpd_engine" rel="Chapter" href="Nethttpd_engine.html">
<link title="Nethttpd_services" rel="Chapter" href="Nethttpd_services.html">
<link title="Nethttpd_plex" rel="Chapter" href="Nethttpd_plex.html">
<link title="Nethttpd_util" rel="Chapter" href="Nethttpd_util.html">
<link title="Nethttpd_intro" rel="Chapter" href="Nethttpd_intro.html">
<link title="Netmech_scram" rel="Chapter" href="Netmech_scram.html">
<link title="Netmech_scram_gssapi" rel="Chapter" href="Netmech_scram_gssapi.html">
<link title="Netmcore" rel="Chapter" href="Netmcore.html">
<link title="Netmcore_camlbox" rel="Chapter" href="Netmcore_camlbox.html">
<link title="Netmcore_mempool" rel="Chapter" href="Netmcore_mempool.html">
<link title="Netmcore_heap" rel="Chapter" href="Netmcore_heap.html">
<link title="Netmcore_ref" rel="Chapter" href="Netmcore_ref.html">
<link title="Netmcore_array" rel="Chapter" href="Netmcore_array.html">
<link title="Netmcore_sem" rel="Chapter" href="Netmcore_sem.html">
<link title="Netmcore_mutex" rel="Chapter" href="Netmcore_mutex.html">
<link title="Netmcore_condition" rel="Chapter" href="Netmcore_condition.html">
<link title="Netmcore_queue" rel="Chapter" href="Netmcore_queue.html">
<link title="Netmcore_buffer" rel="Chapter" href="Netmcore_buffer.html">
<link title="Netmcore_matrix" rel="Chapter" href="Netmcore_matrix.html">
<link title="Netmcore_hashtbl" rel="Chapter" href="Netmcore_hashtbl.html">
<link title="Netmcore_process" rel="Chapter" href="Netmcore_process.html">
<link title="Netmcore_tut" rel="Chapter" href="Netmcore_tut.html">
<link title="Netmcore_basics" rel="Chapter" href="Netmcore_basics.html">
<link title="Netplex_types" rel="Chapter" href="Netplex_types.html">
<link title="Netplex_mp" rel="Chapter" href="Netplex_mp.html">
<link title="Netplex_mt" rel="Chapter" href="Netplex_mt.html">
<link title="Netplex_log" rel="Chapter" href="Netplex_log.html">
<link title="Netplex_controller" rel="Chapter" href="Netplex_controller.html">
<link title="Netplex_container" rel="Chapter" href="Netplex_container.html">
<link title="Netplex_sockserv" rel="Chapter" href="Netplex_sockserv.html">
<link title="Netplex_workload" rel="Chapter" href="Netplex_workload.html">
<link title="Netplex_main" rel="Chapter" href="Netplex_main.html">
<link title="Netplex_config" rel="Chapter" href="Netplex_config.html">
<link title="Netplex_kit" rel="Chapter" href="Netplex_kit.html">
<link title="Rpc_netplex" rel="Chapter" href="Rpc_netplex.html">
<link title="Netplex_cenv" rel="Chapter" href="Netplex_cenv.html">
<link title="Netplex_semaphore" rel="Chapter" href="Netplex_semaphore.html">
<link title="Netplex_sharedvar" rel="Chapter" href="Netplex_sharedvar.html">
<link title="Netplex_mutex" rel="Chapter" href="Netplex_mutex.html">
<link title="Netplex_encap" rel="Chapter" href="Netplex_encap.html">
<link title="Netplex_mbox" rel="Chapter" href="Netplex_mbox.html">
<link title="Netplex_intro" rel="Chapter" href="Netplex_intro.html">
<link title="Netplex_advanced" rel="Chapter" href="Netplex_advanced.html">
<link title="Netplex_admin" rel="Chapter" href="Netplex_admin.html">
<link title="Netshm" rel="Chapter" href="Netshm.html">
<link title="Netshm_data" rel="Chapter" href="Netshm_data.html">
<link title="Netshm_hashtbl" rel="Chapter" href="Netshm_hashtbl.html">
<link title="Netshm_array" rel="Chapter" href="Netshm_array.html">
<link title="Netshm_intro" rel="Chapter" href="Netshm_intro.html">
<link title="Netconversion" rel="Chapter" href="Netconversion.html">
<link title="Netchannels" rel="Chapter" href="Netchannels.html">
<link title="Netstream" rel="Chapter" href="Netstream.html">
<link title="Mimestring" rel="Chapter" href="Mimestring.html">
<link title="Netmime" rel="Chapter" href="Netmime.html">
<link title="Netsendmail" rel="Chapter" href="Netsendmail.html">
<link title="Neturl" rel="Chapter" href="Neturl.html">
<link title="Netaddress" rel="Chapter" href="Netaddress.html">
<link title="Netbuffer" rel="Chapter" href="Netbuffer.html">
<link title="Netdate" rel="Chapter" href="Netdate.html">
<link title="Netencoding" rel="Chapter" href="Netencoding.html">
<link title="Netulex" rel="Chapter" href="Netulex.html">
<link title="Netaccel" rel="Chapter" href="Netaccel.html">
<link title="Netaccel_link" rel="Chapter" href="Netaccel_link.html">
<link title="Nethtml" rel="Chapter" href="Nethtml.html">
<link title="Netstring_str" rel="Chapter" href="Netstring_str.html">
<link title="Netmappings" rel="Chapter" href="Netmappings.html">
<link title="Netaux" rel="Chapter" href="Netaux.html">
<link title="Nethttp" rel="Chapter" href="Nethttp.html">
<link title="Netpagebuffer" rel="Chapter" href="Netpagebuffer.html">
<link title="Netfs" rel="Chapter" href="Netfs.html">
<link title="Netglob" rel="Chapter" href="Netglob.html">
<link title="Netauth" rel="Chapter" href="Netauth.html">
<link title="Netsockaddr" rel="Chapter" href="Netsockaddr.html">
<link title="Netnumber" rel="Chapter" href="Netnumber.html">
<link title="Rtypes" rel="Chapter" href="Rtypes.html">
<link title="Xdr_mstring" rel="Chapter" href="Xdr_mstring.html">
<link title="Xdr" rel="Chapter" href="Xdr.html">
<link title="Netcompression" rel="Chapter" href="Netcompression.html">
<link title="Netunichar" rel="Chapter" href="Netunichar.html">
<link title="Netchannels_tut" rel="Chapter" href="Netchannels_tut.html">
<link title="Netmime_tut" rel="Chapter" href="Netmime_tut.html">
<link title="Netsendmail_tut" rel="Chapter" href="Netsendmail_tut.html">
<link title="Netulex_tut" rel="Chapter" href="Netulex_tut.html">
<link title="Neturl_tut" rel="Chapter" href="Neturl_tut.html">
<link title="Netstring_pcre" rel="Chapter" href="Netstring_pcre.html">
<link title="Netsys" rel="Chapter" href="Netsys.html">
<link title="Netsys_posix" rel="Chapter" href="Netsys_posix.html">
<link title="Netsys_pollset" rel="Chapter" href="Netsys_pollset.html">
<link title="Netlog" rel="Chapter" href="Netlog.html">
<link title="Netexn" rel="Chapter" href="Netexn.html">
<link title="Netsys_win32" rel="Chapter" href="Netsys_win32.html">
<link title="Netsys_pollset_posix" rel="Chapter" href="Netsys_pollset_posix.html">
<link title="Netsys_pollset_win32" rel="Chapter" href="Netsys_pollset_win32.html">
<link title="Netsys_pollset_generic" rel="Chapter" href="Netsys_pollset_generic.html">
<link title="Netsys_signal" rel="Chapter" href="Netsys_signal.html">
<link title="Netsys_oothr" rel="Chapter" href="Netsys_oothr.html">
<link title="Netsys_xdr" rel="Chapter" href="Netsys_xdr.html">
<link title="Netsys_rng" rel="Chapter" href="Netsys_rng.html">
<link title="Netsys_types" rel="Chapter" href="Netsys_types.html">
<link title="Netsys_mem" rel="Chapter" href="Netsys_mem.html">
<link title="Netsys_tmp" rel="Chapter" href="Netsys_tmp.html">
<link title="Netsys_sem" rel="Chapter" href="Netsys_sem.html">
<link title="Netsys_pmanage" rel="Chapter" href="Netsys_pmanage.html">
<link title="Netgzip" rel="Chapter" href="Netgzip.html">
<link title="Netpop" rel="Chapter" href="Netpop.html">
<link title="Rpc_auth_dh" rel="Chapter" href="Rpc_auth_dh.html">
<link title="Rpc_key_service" rel="Chapter" href="Rpc_key_service.html">
<link title="Rpc_time" rel="Chapter" href="Rpc_time.html">
<link title="Rpc_auth_local" rel="Chapter" href="Rpc_auth_local.html">
<link title="Rpc" rel="Chapter" href="Rpc.html">
<link title="Rpc_program" rel="Chapter" href="Rpc_program.html">
<link title="Rpc_util" rel="Chapter" href="Rpc_util.html">
<link title="Rpc_portmapper_aux" rel="Chapter" href="Rpc_portmapper_aux.html">
<link title="Rpc_packer" rel="Chapter" href="Rpc_packer.html">
<link title="Rpc_transport" rel="Chapter" href="Rpc_transport.html">
<link title="Rpc_client" rel="Chapter" href="Rpc_client.html">
<link title="Rpc_simple_client" rel="Chapter" href="Rpc_simple_client.html">
<link title="Rpc_portmapper_clnt" rel="Chapter" href="Rpc_portmapper_clnt.html">
<link title="Rpc_portmapper" rel="Chapter" href="Rpc_portmapper.html">
<link title="Rpc_server" rel="Chapter" href="Rpc_server.html">
<link title="Rpc_auth_sys" rel="Chapter" href="Rpc_auth_sys.html">
<link title="Rpc_auth_gssapi" rel="Chapter" href="Rpc_auth_gssapi.html">
<link title="Rpc_proxy" rel="Chapter" href="Rpc_proxy.html">
<link title="Rpc_intro" rel="Chapter" href="Rpc_intro.html">
<link title="Rpc_mapping_ref" rel="Chapter" href="Rpc_mapping_ref.html">
<link title="Rpc_intro_gss" rel="Chapter" href="Rpc_intro_gss.html">
<link title="Rpc_ssl" rel="Chapter" href="Rpc_ssl.html">
<link title="Rpc_xti_client" rel="Chapter" href="Rpc_xti_client.html">
<link title="Shell_sys" rel="Chapter" href="Shell_sys.html">
<link title="Shell" rel="Chapter" href="Shell.html">
<link title="Shell_uq" rel="Chapter" href="Shell_uq.html">
<link title="Shell_fs" rel="Chapter" href="Shell_fs.html">
<link title="Shell_intro" rel="Chapter" href="Shell_intro.html">
<link title="Netsmtp" rel="Chapter" href="Netsmtp.html">
<link title="Intro" rel="Chapter" href="Intro.html">
<link title="Platform" rel="Chapter" href="Platform.html">
<link title="Foreword" rel="Chapter" href="Foreword.html">
<link title="Ipv6" rel="Chapter" href="Ipv6.html">
<link title="Regexp" rel="Chapter" href="Regexp.html"><link title="Common exceptions" rel="Section" href="#1_Commonexceptions">
<link title="Environments" rel="Section" href="#1_Environments">
<link title="Commands" rel="Section" href="#1_Commands">
<link title="Processes" rel="Section" href="#1_Processes">
<link title="Jobs" rel="Section" href="#1_Jobs">
<link title="Removed functions" rel="Section" href="#1_Removedfunctions">
<link title="Debugging" rel="Section" href="#1_Debugging">
<title>Ocamlnet 3 Reference Manual : Shell_sys</title>
</head>
<body>
<div class="navbar"><a class="pre" href="Rpc_xti_client.html" title="Rpc_xti_client">Previous</a>
&nbsp;<a class="up" href="index.html" title="Index">Up</a>
&nbsp;<a class="post" href="Shell.html" title="Shell">Next</a>
</div>
<h1>Module <a href="type_Shell_sys.html">Shell_sys</a></h1>
<pre><span class="keyword">module</span> Shell_sys: <code class="code">sig</code> <a href="Shell_sys.html">..</a> <code class="code">end</code></pre><div class="info">
Calls external programs, creates pipelines, etc. (full interface)<br>
</div>
<hr width="100%">
<br>
This module is now thread-safe (as of May 2009), provided the
    threads do no share the same <code class="code">Shell</code> or <code class="code">Shell_sys</code> values.
    Problems reported earlier here have been resolved.<br>
<br>
If you get errors like "Netsys_posix.watch_subprocess: uninitialized"
    you should call <a href="Shell_sys.html#VALinstall_job_handlers"><code class="code">Shell_sys.install_job_handlers</code></a>.<br>
<br>
<h1 id="1_Commonexceptions">Common exceptions</h1><br>
<pre><span id="EXCEPTIONFatal_error"><span class="keyword">exception</span> Fatal_error</span> <span class="keyword">of</span> <code class="type">exn</code></pre>
<div class="info">
An error is fatal if it is not possible to recover from it in a
 predictable manner. In this case, many function wrap such exceptions
 <code class="code">x</code> into <code class="code">Fatal_error x</code>.<br>
</div>
<br>
<h1 id="1_Environments">Environments</h1><br>
<pre><span id="TYPEenvironment"><span class="keyword">type</span> <code class="type"></code>environment</span> </pre>
<div class="info">
The abstract type of a process environment<br>
</div>

<pre><span id="VALcreate_env"><span class="keyword">val</span> create_env</span> : <code class="type">unit -> <a href="Shell_sys.html#TYPEenvironment">environment</a></code></pre><div class="info">
Creates an empty environment<br>
</div>
<pre><span id="VALcurrent_env"><span class="keyword">val</span> current_env</span> : <code class="type">unit -> <a href="Shell_sys.html#TYPEenvironment">environment</a></code></pre><div class="info">
Returns the environment of the current process as abstract environment
 value<br>
</div>
<pre><span id="VALcopy_env"><span class="keyword">val</span> copy_env</span> : <code class="type"><a href="Shell_sys.html#TYPEenvironment">environment</a> -> <a href="Shell_sys.html#TYPEenvironment">environment</a></code></pre><div class="info">
Copies an environment<br>
</div>
<pre><span id="VALset_env"><span class="keyword">val</span> set_env</span> : <code class="type"><a href="Shell_sys.html#TYPEenvironment">environment</a> -> string array -> unit</code></pre><div class="info">
Sets the contents of the environment to the passed string array<br>
</div>
<pre><span id="VALget_env"><span class="keyword">val</span> get_env</span> : <code class="type"><a href="Shell_sys.html#TYPEenvironment">environment</a> -> string array</code></pre><div class="info">
Gets the contents of the environment as string array<br>
</div>
<pre><span id="VALiter_env"><span class="keyword">val</span> iter_env</span> : <code class="type">f:(string -> unit) -> <a href="Shell_sys.html#TYPEenvironment">environment</a> -> unit</code></pre><div class="info">
Iterates over the strings of the environment, and calls
 <code class="code">f s</code> for every string <code class="code">s</code>.<br>
</div>
<pre><span id="VALset_env_var"><span class="keyword">val</span> set_env_var</span> : <code class="type"><a href="Shell_sys.html#TYPEenvironment">environment</a> -> string -> string -> unit</code></pre><div class="info">
<code class="code">set_env_var env varname varval</code>: Sets the value of the variable
 <code class="code">varname</code> in the environment <code class="code">env</code> to <code class="code">varval</code>.<br>
</div>
<pre><span id="VALget_env_var"><span class="keyword">val</span> get_env_var</span> : <code class="type"><a href="Shell_sys.html#TYPEenvironment">environment</a> -> string -> string</code></pre><div class="info">
Returns the value of the variable in the environment<br>
</div>
<pre><span id="VALiter_env_vars"><span class="keyword">val</span> iter_env_vars</span> : <code class="type">f:(string -> string -> unit) -> <a href="Shell_sys.html#TYPEenvironment">environment</a> -> unit</code></pre><div class="info">
Iterates over the variables of the environment, and calls
 <code class="code">f name value</code> for every variable with <code class="code">name</code> and <code class="code">value</code>.<br>
</div>
<br>
<h1 id="1_Commands">Commands</h1><br>
<pre><span id="TYPEcommand"><span class="keyword">type</span> <code class="type"></code>command</span> </pre>
<div class="info">
A command describes how to start a new process<br>
</div>

<pre><span id="VALcommand"><span class="keyword">val</span> command</span> : <code class="type">?cmdname:string -><br>       ?arguments:string array -><br>       ?chdir:string -><br>       ?environment:<a href="Shell_sys.html#TYPEenvironment">environment</a> -><br>       ?descriptors:Unix.file_descr list -><br>       ?assignments:(Unix.file_descr * Unix.file_descr) list -><br>       filename:string -> unit -> <a href="Shell_sys.html#TYPEcommand">command</a></code></pre><div class="info">
Creates a command from the passed arguments:
<p>

<br>
</div>
<div class="param_info"><code class="code">cmdname</code> : The name of the command passed in <code class="code">argv[0]</code>. By
   default, this argument is derived from <code class="code">filename</code>.</div>
<div class="param_info"><code class="code">arguments</code> : The arguments of the command (starting with the
   first real argument, skipping <code class="code">cmdname</code>). By default <code class="code"> [] </code>.</div>
<div class="param_info"><code class="code">chdir</code> : Before the command is executed it is changed to
   this directory.</div>
<div class="param_info"><code class="code">environment</code> : The environment of the command. By default, the
   current environment</div>
<div class="param_info"><code class="code">descriptors</code> : The list of file descriptors to share with the
   current process. In the subprocess only those descriptors remain open
   that are either mentioned in <code class="code">descriptors</code>, or that are the final target
   of assignments. By default, <code class="code"> [stdin; stdout; stderr] </code>.
<p>

 Note that only the <b>final targets</b> of assignments remain open in the
 subprocess (unless they are also listed in <code class="code">descriptors</code>). If there
 are cascaded assignments like <code class="code"> (fd1, fd2); (fd2, fd3) </code> the intermediate
 descriptors like <code class="code">fd2</code> are not considered as final targets; only <code class="code">fd3</code>
 would be a final target in this example.</div>
<div class="param_info"><code class="code">assignments</code> : A list of descriptor pairs <code class="code"> (fd_from,fd_to) </code>.
   The descriptor <code class="code">fd_from</code> in the current process will be assigned
   to <code class="code">fd_to</code> in the subprocess started for the command. 
   The list of assignments is executed sequentially, so
   later assignments must take the effect of previous assignments
   into account. For example, to make stderr of the subprocess write 
   to stdout of the parent process, pass <code class="code"> [(stdout; stderr)] </code>. <ul>
<li>By default, there are no assignments.</li>
</ul>
</div>
<div class="param_info"><code class="code">filename</code> : The name of the executable to start. The executable
   file is not searched, use <a href="Shell_sys.html#VALlookup_executable"><code class="code">Shell_sys.lookup_executable</code></a> for this
   purpose.</div>
<pre><span id="EXCEPTIONExecutable_not_found"><span class="keyword">exception</span> Executable_not_found</span> <span class="keyword">of</span> <code class="type">string</code></pre>
<div class="info">
Raised when an executable file cannot be found; the argument is the
  search name<br>
</div>
<pre><span id="VALlookup_executable"><span class="keyword">val</span> lookup_executable</span> : <code class="type">?path:string list -> string -> string</code></pre><div class="info">
Searches an executable file. If the passed search name contains a
 slash, it is expected that this name is already the path name of the
 executable. If the search name does not contain a slash character,
 it is searched in the directories enumerated by the search path.
<p>

<br>
</div>
<div class="param_info"><code class="code">path</code> : The search path. By default, the contents of the
   variable PATH of the current environment, split by ':', are
   used (Win32: SearchPath is used)</div>
<pre><span id="VALget_cmdname"><span class="keyword">val</span> get_cmdname</span> : <code class="type"><a href="Shell_sys.html#TYPEcommand">command</a> -> string</code></pre><div class="info">
Returns the name of the command<br>
</div>
<pre><span id="VALget_arguments"><span class="keyword">val</span> get_arguments</span> : <code class="type"><a href="Shell_sys.html#TYPEcommand">command</a> -> string array</code></pre><div class="info">
Returns the argument array of the command (skipping the command name)<br>
</div>
<pre><span id="VALget_chdir"><span class="keyword">val</span> get_chdir</span> : <code class="type"><a href="Shell_sys.html#TYPEcommand">command</a> -> string option</code></pre><div class="info">
Returns the <code class="code">chdir</code> parameter of the command<br>
</div>
<pre><span id="VALget_environment"><span class="keyword">val</span> get_environment</span> : <code class="type"><a href="Shell_sys.html#TYPEcommand">command</a> -> <a href="Shell_sys.html#TYPEenvironment">environment</a></code></pre><div class="info">
Returns the designated environment of the command<br>
</div>
<pre><span id="VALget_descriptors"><span class="keyword">val</span> get_descriptors</span> : <code class="type"><a href="Shell_sys.html#TYPEcommand">command</a> -> Unix.file_descr list</code></pre><div class="info">
Returns the list of active descriptors<br>
</div>
<pre><span id="VALget_assignments"><span class="keyword">val</span> get_assignments</span> : <code class="type"><a href="Shell_sys.html#TYPEcommand">command</a> -> (Unix.file_descr * Unix.file_descr) list</code></pre><div class="info">
Returns the list of assignments <code class="code"> (fd_from,fd_to) </code><br>
</div>
<pre><span id="VALget_filename"><span class="keyword">val</span> get_filename</span> : <code class="type"><a href="Shell_sys.html#TYPEcommand">command</a> -> string</code></pre><div class="info">
Returns the file name of the executable<br>
</div>
<pre><span id="VALset_cmdname"><span class="keyword">val</span> set_cmdname</span> : <code class="type"><a href="Shell_sys.html#TYPEcommand">command</a> -> string -> unit</code></pre><div class="info">
Sets the command name<br>
</div>
<pre><span id="VALset_arguments"><span class="keyword">val</span> set_arguments</span> : <code class="type"><a href="Shell_sys.html#TYPEcommand">command</a> -> string array -> unit</code></pre><div class="info">
Sets the argument array<br>
</div>
<pre><span id="VALset_chdir"><span class="keyword">val</span> set_chdir</span> : <code class="type"><a href="Shell_sys.html#TYPEcommand">command</a> -> string option -> unit</code></pre><div class="info">
Sets the <code class="code">chdir</code> parameter of the command<br>
</div>
<pre><span id="VALset_environment"><span class="keyword">val</span> set_environment</span> : <code class="type"><a href="Shell_sys.html#TYPEcommand">command</a> -> <a href="Shell_sys.html#TYPEenvironment">environment</a> -> unit</code></pre><div class="info">
Sets the environment<br>
</div>
<pre><span id="VALset_descriptors"><span class="keyword">val</span> set_descriptors</span> : <code class="type"><a href="Shell_sys.html#TYPEcommand">command</a> -> Unix.file_descr list -> unit</code></pre><div class="info">
Sets the list of active descriptors<br>
</div>
<pre><span id="VALset_assignments"><span class="keyword">val</span> set_assignments</span> : <code class="type"><a href="Shell_sys.html#TYPEcommand">command</a> -> (Unix.file_descr * Unix.file_descr) list -> unit</code></pre><div class="info">
Sets the list of assignments <code class="code"> (fd_from,fd_to) </code><br>
</div>
<pre><span id="VALset_filename"><span class="keyword">val</span> set_filename</span> : <code class="type"><a href="Shell_sys.html#TYPEcommand">command</a> -> string -> unit</code></pre><div class="info">
Sets the file name of the executable to start<br>
</div>
<pre><span id="VALcopy_command"><span class="keyword">val</span> copy_command</span> : <code class="type"><a href="Shell_sys.html#TYPEcommand">command</a> -> <a href="Shell_sys.html#TYPEcommand">command</a></code></pre><div class="info">
Returns a duplicate of the command description<br>
</div>
<pre><span id="VALis_executable"><span class="keyword">val</span> is_executable</span> : <code class="type"><a href="Shell_sys.html#TYPEcommand">command</a> -> bool</code></pre><div class="info">
Returns <code class="code">true</code> if there is an executable file for the command, and
 it is permitted to run this file (as stated by the file permissions).
<p>

 <code class="code">false</code> means that the command can definitely not be executed. However,
 even if the function returns <code class="code">true</code> there may be still reasons that
 execution will fail.<br>
</div>
<br>
<h1 id="1_Processes">Processes</h1><br>
<pre><span id="TYPEprocess"><span class="keyword">type</span> <code class="type"></code>process</span> </pre>
<div class="info">
A process is the running instance of a command (a Unix process)<br>
</div>

<pre><code><span id="TYPEgroup_action"><span class="keyword">type</span> <code class="type"></code>group_action</span> = </code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgroup_action.New_bg_group"><span class="constructor">New_bg_group</span></span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Start process in new background process group</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgroup_action.New_fg_group"><span class="constructor">New_fg_group</span></span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Start process in new foreground process group</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgroup_action.Join_group"><span class="constructor">Join_group</span></span> <span class="keyword">of</span> <code class="type">int</code></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Started process joins this existing process group</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgroup_action.Current_group"><span class="constructor">Current_group</span></span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Started process remains in the current group</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr></table>

<div class="info">
Determines in which process group the new process will run<br>
</div>

<pre><code><span id="TYPEfwd_mode"><span class="keyword">type</span> <code class="type"></code>fwd_mode</span> = </code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTfwd_mode.No_forward"><span class="constructor">No_forward</span></span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >No forwarding of keyboard signals</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTfwd_mode.Forward_to_process"><span class="constructor">Forward_to_process</span></span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Forward signals directly to subprocess</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTfwd_mode.Forward_to_group"><span class="constructor">Forward_to_group</span></span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Forward signals to the process group of the subprocess</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr></table>

<div class="info">
Determines whether and how keyboard signals (SIGINT, SIGQUIT) are
      forwarded from the caller to the new child. There is no forwarding
      in Win32 - all console applications get the keyboard signals anyway.<br>
</div>

<pre><span id="VALrun"><span class="keyword">val</span> run</span> : <code class="type">?group:<a href="Shell_sys.html#TYPEgroup_action">group_action</a> -><br>       ?forward_mode:<a href="Shell_sys.html#TYPEfwd_mode">fwd_mode</a> -><br>       ?pipe_assignments:(Unix.file_descr * Unix.file_descr) list -><br>       <a href="Shell_sys.html#TYPEcommand">command</a> -> <a href="Shell_sys.html#TYPEprocess">process</a></code></pre><div class="info">
Executes the command concurrently with the current process. The function
 does not wait until the process terminates; it returns immediately after
 the <code class="code">exec</code> system call has been successfully performed; errors that
 occur until <code class="code">exec</code> are caught and reported as exception (even errors
 in the fresh subprocess).
<p>

 On error, one can assume that the process state has been cleaned up:
 any forked child process has terminated; any modifications of the global
 process state has been restored. 
<p>

 File descriptor assignments: First, the assignments in <code class="code">pipe_assignments</code>
 are performed, then the assignments contained in the command. The
 <code class="code">pipe_assignments</code> are interpreted as parallel assignment, not
 as sequential assignment.
<p>

 Note: For users without very special needs, it is recommended to run
 jobs instead of processes. See below for the job API.
<p>

<br>
</div>
<div class="param_info"><code class="code">group</code> : Determines in which process group the new process will
   run. By default <code class="code">Current_group</code>.</div>
<div class="param_info"><code class="code">forward_mode</code> : Whether and how to forward keyboard signals
   to the new child. By default <code class="code">No_forward</code>. The Win32 implementation
   ignores this argument.</div>
<div class="param_info"><code class="code">pipe_assignments</code> : A list of descriptor pairs <code class="code">(fd_from,fd_to)</code>.
   The descriptor <code class="code">fd_from</code> in the current process will be assigned
   to <code class="code">fd_to</code> in the started subprocess. In order to
   take effect, <code class="code">fd_to</code> must also be passed in the <code class="code">descriptors</code>
   property of the started command.
   Furthermore, <code class="code">fd_from</code> may or may not be member of <code class="code">descriptors</code>;
   in the first case it will remain open, in the latter case it will
   be closed. The list of assignments is executed in parallel. For
   example, to swap the roles of stdout and stderr, pass the list
   <code class="code"> [(stdout,stderr); (stderr,stdout)] </code>.</div>
<pre><span id="VALprocess_id"><span class="keyword">val</span> process_id</span> : <code class="type"><a href="Shell_sys.html#TYPEprocess">process</a> -> int</code></pre><div class="info">
Returns the process ID of the process<br>
</div>
<pre><span id="VALstatus"><span class="keyword">val</span> status</span> : <code class="type"><a href="Shell_sys.html#TYPEprocess">process</a> -> Unix.process_status</code></pre><div class="info">
Reports the status so far known: If the process 
 has terminated, the status of the process is returned.
 If the process is still running, <code class="code">Not_found</code> will be raised.<br>
</div>
<pre><span id="VALcommand_of_process"><span class="keyword">val</span> command_of_process</span> : <code class="type"><a href="Shell_sys.html#TYPEprocess">process</a> -> <a href="Shell_sys.html#TYPEcommand">command</a></code></pre><div class="info">
Returns the command that is now running as the process<br>
</div>
<pre><span id="VALcall"><span class="keyword">val</span> call</span> : <code class="type"><a href="Shell_sys.html#TYPEcommand">command</a> -> <a href="Shell_sys.html#TYPEprocess">process</a></code></pre><div class="info">
Executes the command and waits until the process terminates
 (synchronous execution a la <code class="code">system</code>, but no intermediate shell).
 <code class="code">status</code> is guaranteed to return WEXITED or WSIGNALED.<br>
</div>
<pre><span id="VALkill"><span class="keyword">val</span> kill</span> : <code class="type">?signal:int -> <a href="Shell_sys.html#TYPEprocess">process</a> -> unit</code></pre><div class="info">
Sends a signal to the passed process.
<p>

<br>
</div>
<div class="param_info"><code class="code">signal</code> : The signal to send, by default SIGTERM</div>
<br>
<h1 id="1_Jobs">Jobs</h1><br>
<br>
A <code class="code">job</code> is the description of how to run several commands which are
 linked by pipelines (or which are just a logical unit). A <code class="code">job_instance</code>
 is the running instance of a job.
<p>

 Jobs are implemented on a higher layer than commands; the
 following means of the operating system are used by job
 invocations:<ul>
<li>Normally a <code class="code">job_instance</code> corresponds to a Unix process group. In
   this case the last added command will result in the process group
   leader.</li>
<li>Controlling the execution of jobs requires that signal
   handlers are set in many cases (see <code class="code">install_job_handlers</code>)</li>
<li>The processes of jobs are often interconnected by pipelines
   (see <code class="code">add_pipeline</code>).</li>
<li>It is possible to handle pipelines between the current process and
   processes of the job (see <code class="code">add_producer</code> and <code class="code">add_consumer</code>)</li>
</ul>
<br>
<br>
<b>Important:</b>
<p>

 In order to run jobs efficiently (without busy waiting) and properly
 it is strongly recommended to install the signal handlers using
 <code class="code">install_job_handlers</code><br>
<pre><span id="TYPEjob"><span class="keyword">type</span> <code class="type"></code>job</span> </pre>

<pre><span id="TYPEjob_instance"><span class="keyword">type</span> <code class="type"></code>job_instance</span> </pre>

<pre><span id="VALnew_job"><span class="keyword">val</span> new_job</span> : <code class="type">unit -> <a href="Shell_sys.html#TYPEjob">job</a></code></pre><div class="info">
Creates a new job descriptor. Initially the job is empty, but you can
 fill it with commands (<code class="code">add_command</code>), pipelines (<code class="code">add_pipeline</code>), 
 consumers (<code class="code">add_consumer</code>) and producers (<code class="code">add_producer</code>).
 When the job is set up, you can start it (<code class="code">run_job</code>/<code class="code">finish_job</code> or
 <code class="code">call_job</code>).<br>
</div>
<pre><span id="VALadd_command"><span class="keyword">val</span> add_command</span> : <code class="type"><a href="Shell_sys.html#TYPEcommand">command</a> -> <a href="Shell_sys.html#TYPEjob">job</a> -> unit</code></pre><div class="info">
Adds a command to a job. 
<p>

 Note that you cannot add the same command twice; however you can
 add a copy of a command already belonging to the job.<br>
</div>
<pre><span id="VALadd_pipeline"><span class="keyword">val</span> add_pipeline</span> : <code class="type">?bidirectional:bool -><br>       ?src_descr:Unix.file_descr -><br>       ?dest_descr:Unix.file_descr -><br>       src:<a href="Shell_sys.html#TYPEcommand">command</a> -> dest:<a href="Shell_sys.html#TYPEcommand">command</a> -> <a href="Shell_sys.html#TYPEjob">job</a> -> unit</code></pre><div class="info">
Adds a pipeline which redirects the output of the command <code class="code">src</code> to the
 input of the command <code class="code">dest</code>.
<p>

<br>
</div>
<div class="param_info"><code class="code">bidirectional</code> : if <code class="code">false</code> (default), a classical pipe is created
    to connect the file descriptors. This normally restricts the data
    flow to one direction. If <code class="code">true</code>, a socketpair is created which is
    roughly a bidirectional pipe. In this case, data flow in both
    directions is possible.</div>
<div class="param_info"><code class="code">src_descr</code> : determines the file descriptor of the source command
    which is redirected. This is by default <code class="code">stdout</code>.</div>
<div class="param_info"><code class="code">dest_descr</code> : determines the file descriptor of the destination
    command to which the data stream is sent. This is by default <code class="code">stdin</code>.</div>
<pre><span id="VALadd_producer"><span class="keyword">val</span> add_producer</span> : <code class="type">?descr:Unix.file_descr -><br>       producer:(Unix.file_descr -> bool) -><br>       <a href="Shell_sys.html#TYPEcommand">command</a> -> <a href="Shell_sys.html#TYPEjob">job</a> -> unit</code></pre><div class="info">
Adds a producer to the job. A producer transfers data to the
 subprocess realizing the passed command. To do so, a pipe is created
 between the file descriptor <code class="code">descr</code> of the subprocess and another
 descriptor <code class="code">descr'</code> which is open in the current process. The
 function <code class="code">producer</code> is called when data can be written into the
 pipe. The argument of <code class="code">producer</code> is the writing end of the pipe
 <code class="code">descr'</code>. This file descriptor is in non-blocking mode. The
 function <code class="code">producer</code> must close <code class="code">descr'</code> when all data are
 transferred. The return value of <code class="code">producer</code> indicates whether
 the descriptor is still open.
<p>

<br>
</div>
<div class="param_info"><code class="code">descr</code> : The descriptor of the subprocess to which the reading
    end of the pipe is dup'ed. By default <code class="code">stdin</code>.</div>
<pre><span id="VALfrom_string"><span class="keyword">val</span> from_string</span> : <code class="type">?pos:int -><br>       ?len:int -> ?epipe:(unit -> unit) -> string -> Unix.file_descr -> bool</code></pre><div class="info">
<code class="code">from_string ?pos ?len ?epipe s</code> returns a function which can be
 used as <code class="code">producer</code> argument for <code class="code">add_producer</code>. The data transferred
 to the subprocess is taken from the string <code class="code">s</code>. After these data
 are sent, the pipeline is closed.
<p>

<br>
</div>
<div class="param_info"><code class="code">pos</code> : The position in <code class="code">s</code> where the data slice to transfer begins.
    By default <code class="code">0</code>.</div>
<div class="param_info"><code class="code">len</code> : The length of the data slice to transfer. By default,
    all bytes from the start position <code class="code">pos</code> to the end of the 
    string are taken.</div>
<div class="param_info"><code class="code">epipe</code> : This function is called when the pipeline breaks
    (EPIPE). Default: the empty function. EPIPE exceptions are
    always caught, and implicitly handled by closing the pipeline.</div>
<pre><span id="VALfrom_stream"><span class="keyword">val</span> from_stream</span> : <code class="type">?epipe:(unit -> unit) -> string Stream.t -> Unix.file_descr -> bool</code></pre><div class="info">
<code class="code">from_stream ?epipe s</code> returns a function which can be
 used as <code class="code">producer</code> argument for <code class="code">add_producer</code>. The data transferred
 to the subprocess is taken from the string stream <code class="code">s</code>. After these data
 are sent, the pipeline is closed.
<p>

<br>
</div>
<div class="param_info"><code class="code">epipe</code> : This function is called when the pipeline breaks
    (EPIPE). Default: the empty function. EPIPE exceptions are
    always caught, and implicitly handled by closing the pipeline.</div>
<pre><span id="VALadd_consumer"><span class="keyword">val</span> add_consumer</span> : <code class="type">?descr:Unix.file_descr -><br>       consumer:(Unix.file_descr -> bool) -><br>       <a href="Shell_sys.html#TYPEcommand">command</a> -> <a href="Shell_sys.html#TYPEjob">job</a> -> unit</code></pre><div class="info">
Adds a consumer to the job. A consumer transfers data from the
 subprocess realizing the passed command to the current process. 
 To do so, a pipe is created between the file descriptor <code class="code">descr</code>
 of the subprocess and another descriptor <code class="code">descr'</code> which is open
 in the current process. The function <code class="code">consumer</code> is called when 
 data can be read from the pipe. The argument of <code class="code">consumer</code> is 
 reading end of the pipe <code class="code">descr'</code>. This file descriptor is in
 non-blocking mode. The function <code class="code">consumer</code> must close <code class="code">descr'</code> 
 after EOF is detected. The return value of <code class="code">consumer</code> indicates whether
 the descriptor is still open.
<p>

<br>
</div>
<div class="param_info"><code class="code">descr</code> : The descriptor of the subprocess to which the writing
    end of the pipe is dup'ed. By default <code class="code">stdout</code>.</div>
<pre><span id="VALto_buffer"><span class="keyword">val</span> to_buffer</span> : <code class="type">Buffer.t -> Unix.file_descr -> bool</code></pre><div class="info">
<code class="code">to_buffer b</code> returns a function which can be
 used as <code class="code">consumer</code> argument for <code class="code">add_consumer</code>. The data received
 from the subprocess is added to the buffer <code class="code">b</code>.<br>
</div>
<pre><code><span id="TYPEgroup_mode"><span class="keyword">type</span> <code class="type"></code>group_mode</span> = </code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgroup_mode.Same_as_caller"><span class="constructor">Same_as_caller</span></span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The job runs in the same process group as the current process</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgroup_mode.Foreground"><span class="constructor">Foreground</span></span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The job runs in a new foreground process group</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgroup_mode.Background"><span class="constructor">Background</span></span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The job runs in a new background process group</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr></table>

<div class="info">
Specifies how the job instance is related to process groups<br>
</div>

<pre><span id="VALrun_job"><span class="keyword">val</span> run_job</span> : <code class="type">?mode:<a href="Shell_sys.html#TYPEgroup_mode">group_mode</a> -><br>       ?forward_signals:bool -> <a href="Shell_sys.html#TYPEjob">job</a> -> <a href="Shell_sys.html#TYPEjob_instance">job_instance</a></code></pre><div class="info">
Invokes the commands of the job such that they run concurrently
 with the main process.
<p>

 The function returns a <code class="code">job_instance</code>, i.e. a value recording which
 processes are started, and how they are related. Furthermore, the
 function has the side effect of adding the
 job to the global list of current jobs.
<p>

 The <code class="code">mode</code> argument specifies whether a new Unix process group is
 created for the job instance. A process group has the advantage that
 it is possible to send signals to all processes of the group at
 once. For example, one can terminate a group by sending SIGTERM
 to it: All member processes get the signal. Usually, these are not only
 the subprocesses initially created, but also further processes 
 started by the initial members.
<p>

 So if it is necessary to send signals to the processes of the job,
 it will be advantegous to run it in a new process group. However,
 this also means that signals sent to the current process group
 are not automatically forwarded to the created process group. For
 example, if the current process group is terminated, the job
 will continue running, because it is member of a different process
 group. One has to explicitly catch and forward signals to avoid
 wild-running jobs.
<p>

 The moral of the story is that one should only create new process
 groups when it is necessary (e.g. the user must be able to stop
 an action at any time). Furthermore, signal forwarding must be
 configured.
<p>

 The Unix shell also allows the programmer to specify process group
 handling to a certain extent. Normally, commands are executed in the
 same process group as the caller. The syntax "command &amp;" forces that
 the command is run in a new background process group. There is another
 situation when new process groups are created: when a new <b>interactive</b> 
 shell is started the commands are run in new foreground process groups
 (so the keyboard signals like CTRL-C work).
<p>

<br>
</div>
<div class="param_info"><code class="code">mode</code> : Specifies the process group handling. By default, the
   job is executed in the same process group as the current process
   (<code class="code">Same_as_caller</code>). The value <code class="code">Background</code> causes that a new
   background process group is started. The value <code class="code">Foreground</code> causes
   that a new foreground process group is started. For the latter,
   it is required that there is a controlling terminal (i.e. it
   does not work for daemons). Any existing foreground process group
   (there is at most one) is put into the background, but this is
   not restored when the job is over (the caller must do this).
   Foreground process groups should be avoided unless you are
   writing an interactive shell interpreter.</div>
<div class="param_info"><code class="code">forward_signals</code> : If <code class="code">true</code>, the default, keyboard signals
   (SIGINT, SIGQUIT) delivered to the current process are forwarded to 
   the job. This has only a meaning if the job is running as 
   background process group. Furthermore, it is required that
   <code class="code">install_job_handlers</code> has been called to enable signal 
   forwarding.
<p>

 The function returns normally if at least one process could be started.
 If no process was startable (i.e. the first command was not startable), 
 an exception is raised. If one or more processes could be started but
 not all, <code class="code">job_status</code> will return <code class="code">Job_partially_running</code>. The caller 
 should then discard the job and any intermediate result that might
 already have been produced by the partial job.
<p>

 When all processes could be started and no other exceptional condition
 happened, the function sets <code class="code">job_status</code> to <code class="code">Job_running</code>.</div>
<pre><span id="TYPEjob_handler_engine_type"><span class="keyword">class type</span> <code class="type">['t]</code> <a href="Shell_sys.job_handler_engine_type-c.html">job_handler_engine_type</a></span> = <code class="code">object</code> <a href="Shell_sys.job_handler_engine_type-c.html">..</a> <code class="code">end</code></pre><div class="info">
This type of engine also returns the <code class="code">job</code> and the <code class="code">job_instance</code>.
</div>
<pre><span name="TYPEjob_engine"><span class="keyword">class</span> <a href="Shell_sys.job_engine-c.html">job_engine</a></span> : <code class="type"><a href="Unixqueue.event_system-c.html">Unixqueue.event_system</a> -> <a href="Shell_sys.html#TYPEjob_instance">job_instance</a> -> </code><code class="type">[unit]</code> <code class="type"><a href="Shell_sys.job_handler_engine_type-c.html">job_handler_engine_type</a></code></pre><div class="info">
The <code class="code">job_engine</code> watches the job, and looks whether the processes
      are finished, and if so, it records the process statuses.
</div>
<pre><span id="VALfinish_job"><span class="keyword">val</span> finish_job</span> : <code class="type"><a href="Shell_sys.html#TYPEjob_instance">job_instance</a> -> unit</code></pre><div class="info">
This creates a <code class="code">job_engine</code> internally and runs until it is
 finished, i.e. until the job has been executed.
<p>

 In previous version of Ocamlnet there was an optional <code class="code">sys</code>
 argument. This is gone now. Also, the error handling is different.
 It is no longer possible to restart <code class="code">finish_job</code> when an error
 happens.<br>
</div>
<pre><span id="VALcall_job"><span class="keyword">val</span> call_job</span> : <code class="type">?mode:<a href="Shell_sys.html#TYPEgroup_mode">group_mode</a> -><br>       ?forward_signals:bool -><br>       ?onerror:(<a href="Shell_sys.html#TYPEjob_instance">job_instance</a> -> unit) -><br>       <a href="Shell_sys.html#TYPEjob">job</a> -> <a href="Shell_sys.html#TYPEjob_instance">job_instance</a></code></pre><div class="info">
Starts the job (see <code class="code">run_job</code>) and waits until it finishes (see
 <code class="code">finish_job</code>); i.e. <code class="code">call_job = run_job + finish_job</code>.
 The function returns normally if all processes can be started; you can
 examine <code class="code">job_status</code> of the result to get the information whether all
 processes returned the exit code 0.
<p>

<br>
</div>
<div class="param_info"><code class="code">mode</code> : See <code class="code">run_job</code></div>
<div class="param_info"><code class="code">forward_signals</code> : See <code class="code">run_job</code></div>
<div class="param_info"><code class="code">onerror</code> : If not all of the processes can be started, the
    function passed by <code class="code">onerror</code> is invoked. By default, this
    function calls <code class="code">abandon_job</code> to stop the already running
    processes. After the <code class="code">onerror</code> function has returned, the original 
    exception is raised again. Fatal error conditions are not caught.</div>
<pre><span id="VALprocesses"><span class="keyword">val</span> processes</span> : <code class="type"><a href="Shell_sys.html#TYPEjob_instance">job_instance</a> -> <a href="Shell_sys.html#TYPEprocess">process</a> list</code></pre><div class="info">
Returns the processes that have actually been started for this job
 by <code class="code">run_job</code>; note that the corresponding Unix process group
 may have additional processes (e.g. indirectly started processes).<br>
</div>
<pre><span id="EXCEPTIONNo_Unix_process_group"><span class="keyword">exception</span> No_Unix_process_group</span></pre>
<div class="info">
Raised by functions referring to Unix process groups when the
 job has not been started in its own process group.<br>
</div>
<pre><span id="VALprocess_group_leader"><span class="keyword">val</span> process_group_leader</span> : <code class="type"><a href="Shell_sys.html#TYPEjob_instance">job_instance</a> -> <a href="Shell_sys.html#TYPEprocess">process</a></code></pre><div class="info">
Returns the process group leader process.
 This function is not available for jobs in the mode <code class="code">Same_as_caller</code>.<br>
</div>
<pre><span id="VALprocess_group_id"><span class="keyword">val</span> process_group_id</span> : <code class="type"><a href="Shell_sys.html#TYPEjob_instance">job_instance</a> -> int</code></pre><div class="info">
Returns the Unix ID of the process group as number &gt; 1.
 This function is not available for jobs in the mode <code class="code">Same_as_caller</code>.<br>
</div>
<pre><code><span id="TYPEjob_status"><span class="keyword">type</span> <code class="type"></code>job_status</span> = </code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTjob_status.Job_running"><span class="constructor">Job_running</span></span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >All commands could be started, and at least
 one process is still running</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTjob_status.Job_partially_running"><span class="constructor">Job_partially_running</span></span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Not all commands could be started, and at least
 one process is still running</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTjob_status.Job_ok"><span class="constructor">Job_ok</span></span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >all processes terminated with exit code 0</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTjob_status.Job_error"><span class="constructor">Job_error</span></span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >all processes terminated but some abnormally</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTjob_status.Job_abandoned"><span class="constructor">Job_abandoned</span></span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >the job has been abandoned (see <code class="code">abandon_job</code>)</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr></table>

<div class="info">
Indicates the status of the job<br>
</div>

<pre><span id="VALjob_status"><span class="keyword">val</span> job_status</span> : <code class="type"><a href="Shell_sys.html#TYPEjob_instance">job_instance</a> -> <a href="Shell_sys.html#TYPEjob_status">job_status</a></code></pre><div class="info">
Returns the status. The status may only change after <code class="code">finish_job</code>
 has been called:
<p>
<ul>
<li>after <code class="code">run_job</code>: status is <code class="code">Job_running</code> or <code class="code">Job_partially_running</code></li>
<li>after <code class="code">finish_job</code>: if returning normally: status is <code class="code">Job_ok</code> or 
   <code class="code">Job_error</code>. After an exception happened the other states are possible,
   too</li>
</ul>
<br>
</div>
<pre><span id="VALkill_process_group"><span class="keyword">val</span> kill_process_group</span> : <code class="type">?signal:int -> <a href="Shell_sys.html#TYPEjob_instance">job_instance</a> -> unit</code></pre><div class="info">
Kills the process group if it is still (at least partially) running.
 This operation is not available if the mode is <code class="code">Same_as_caller</code>
 (exception <code class="code">No_Unix_process_group</code>).
<p>

 Note 1: In the Unix terminology, "killing a job" only means to send
 a signal to the job. So the job may continue running, or it may
 terminate; in general we do not know this. Because of this, the job
 will still have an entry in the job list.
<p>

 Note 2: Because sub-sub-processes are also killed, this function may send
 the signal to more processes than kill_processes (below). On the other
 hand, it is possible that sub-processes change their group ID such that
 it is also possible that this function sends the signal to fewer processes
 than kill_processes.
<p>

<br>
</div>
<div class="param_info"><code class="code">signal</code> : The signal number to send (O'Caml signal numbers as
    used by the <code class="code">Sys</code> module). Default is <code class="code">Sys.sigterm</code>.</div>
<pre><span id="VALkill_processes"><span class="keyword">val</span> kill_processes</span> : <code class="type">?signal:int -> <a href="Shell_sys.html#TYPEjob_instance">job_instance</a> -> unit</code></pre><div class="info">
Kills the individual processes of the job which are still running.
<p>

<br>
</div>
<div class="param_info"><code class="code">signal</code> : The signal number to send (O'Caml signal numbers as
    used by the <code class="code">Sys</code> module). Default is <code class="code">Sys.sigterm</code>.</div>
<pre><span id="VALcancel_job"><span class="keyword">val</span> cancel_job</span> : <code class="type">?signal:int -> <a href="Shell_sys.html#TYPEjob_instance">job_instance</a> -> unit</code></pre><div class="info">
Tries to get rid of a running job. If the mode is <code class="code">Same_as_caller</code>, the
 signal is sent to the processes individually. If the mode is
 <code class="code">Foreground</code> or <code class="code">Background</code>, the signal is sent to the process group 
 corresponding to the job.
<p>

 This function removes the job from the job list; i.e. it is no longer
 watched. Because of some magic spells it is guaranteed that the job dies
 immediately without becoming a zombie (provided you have a SIGCHLD
 handler).
<p>

<br>
</div>
<div class="param_info"><code class="code">signal</code> : The signal number to send (O'Caml signal numbers as
    used by the <code class="code">Sys</code> module). Default is <code class="code">Sys.sigterm</code>.</div>
<pre><span id="VALabandon_job"><span class="keyword">val</span> abandon_job</span> : <code class="type">?signal:int -> <a href="Shell_sys.html#TYPEjob_instance">job_instance</a> -> unit</code></pre><div class="info">
<b>Deprecated</b> name for <code class="code">cancel_job</code><br>
</div>
<pre><span id="EXCEPTIONAlready_installed"><span class="keyword">exception</span> Already_installed</span></pre>
<div class="info">
Raised when the job handlers are already installed<br>
</div>
<pre><span id="VALconfigure_job_handlers"><span class="keyword">val</span> configure_job_handlers</span> : <code class="type">?catch_sigint:bool -><br>       ?catch_sigquit:bool -><br>       ?catch_sigterm:bool -> ?catch_sighup:bool -> ?at_exit:bool -> unit -> unit</code></pre><div class="info">
Configures signal and at_exit handlers for jobs:<ul>
<li>The keyboard signals SIGINT and SIGQUIT are forwarded to all jobs
   which are running in the background (and thus are not
   automatically notified) and want to get such signals (<code class="code">forward_signals</code>).</li>
<li>The signals SIGTERM and SIGHUP are (if the handler is installed) 
   forwarded to all dependent processes (regardless whether they are
   running in their own Unix process group or not, and regardless of
   <code class="code">forward_signals</code>).</li>
<li>The <code class="code">at_exit</code> handler sends a SIGTERM to all dependent processes, too.</li>
</ul>

 In previous versions of Ocamlnet it was also possible to configure
 <code class="code">catch_sigchld</code> to set whether a SIGCHLD handler is installed. This
 is now always done.
<p>

 In previous versions of Ocamlnet there was also a <code class="code">set_sigpipe</code> flag.
 This flag is gone as a SIGPIPE handler is now always installed.
<p>

 The handlers are now managed by <a href="Netsys_signal.html"><code class="code">Netsys_signal</code></a>. The handlers of this
 module set the <code class="code">keep_default</code> flag for SIGINT, SIGQUIT, SIGTERM, and
 SIGHUP, so that the default action for these signals is executed after
 the forwarding to the child processes is done. By setting another
 handler in <a href="Netsys_signal.html"><code class="code">Netsys_signal</code></a> without that flag this behavior can be
 overridden.
<p>

 Note that if an uncaught exception leads to program termination,
 this situation will not be detected; any running jobs will
 not be terminated (sorry, this cannot be fixed).
<p>

 This function sets only which handlers will be installed when
 <code class="code">install_job_handlers</code> (below) is invoked.
 The function fails if the handlers are already installed.
<p>

 Win32: No handlers are installed. It would be desirable to some extent
 that at least <code class="code">at_exit</code> is honoured, however, this is not yet done.
<p>

<br>
</div>
<div class="param_info"><code class="code">catch_sigint</code> : whether to install a SIGINT handler (default: <code class="code">true</code>)</div>
<div class="param_info"><code class="code">catch_sigquit</code> : whether to install a SIGQUIT handler (default: <code class="code">true</code>)</div>
<div class="param_info"><code class="code">catch_sigterm</code> : whether to install a SIGTERM handler (default: <code class="code">true</code>)</div>
<div class="param_info"><code class="code">catch_sighup</code> : whether to install a SIGHUP handler (default: <code class="code">true</code>)</div>
<div class="param_info"><code class="code">at_exit</code> : whether to set the <code class="code">at_exit</code> handler (default: <code class="code">true</code>)</div>
<pre><span id="VALinstall_job_handlers"><span class="keyword">val</span> install_job_handlers</span> : <code class="type">unit -> unit</code></pre><div class="info">
Installs handlers as configured before.
 Raises <code class="code">Already_installed</code> if the handlers are already installed.<br>
</div>
<br>
<h1 id="1_Removedfunctions">Removed functions</h1><br>
<br>
The functions <code class="code">add_rd_polling</code> and <code class="code">add_wr_polling</code> have been removed.
 They were added prior to the merge with the equeue library. Use a 
 Unixqueue now, which is much more powerful.<br>
<br>
Also no longer supported because the type <code class="code">system_handler</code> is gone:
<p>

    <pre class="codepre"><code class="code">type system_handler</code></pre>
<p>

    <pre class="codepre"><code class="code"> type process_event </code></pre>
<p>

    <pre class="codepre"><code class="code">val wait : 
      ?wnohang:bool -&gt;                     (* default: false *)
      ?wuntraced:bool -&gt;                   (* default: false *)
      ?restart:bool -&gt;                     (* default: false *)
      ?check_interval:float -&gt;             (* default: 0.1 *)
      ?read:(Unix.file_descr list) -&gt;      (* default: [] *)
      ?write:(Unix.file_descr list) -&gt;     (* default: [] *)
      ?except:(Unix.file_descr list) -&gt;    (* default: [] *)
      process list -&gt;
        process_event list
    </code></pre>
    <pre class="codepre"><code class="code">val register_job : system_handler -&gt; job_instance -&gt; unit</code></pre>
<p>

    <pre class="codepre"><code class="code">val iter_job_instances : f:(job_instance -&gt; unit) -&gt;  unit</code></pre>
<p>

    <pre class="codepre"><code class="code">val watch_for_zombies : unit -&gt; unit</code></pre>
<p>

    <pre class="codepre"><code class="code">val process_group_expects_signals : job_instance -&gt; bool</code></pre><br>
<br>
<h1 id="1_Debugging">Debugging</h1><br>
<pre><span class="keyword">module</span> <a href="Shell_sys.Debug.html">Debug</a>: <code class="code">sig</code> <a href="Shell_sys.Debug.html">..</a> <code class="code">end</code></pre></body></html>