Ajout de setsid()

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1266 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Xavier Leroy 1997-02-14 16:29:10 +00:00
parent 354fafbf3f
commit d0c1f4366b
5 changed files with 42 additions and 2 deletions

5
configure vendored
View File

@ -480,6 +480,11 @@ if sh hasgot mktime; then
echo "#define HAS_MKTIME" >> s.h
fi
if sh hasgot setsid; then
echo "setsid() found."
echo "#define HAS_SETSID" >> s.h
fi
# Determine the target architecture for the "num" library
case "$host" in

View File

@ -18,7 +18,7 @@ OBJS=accept.o access.o addrofstr.o alarm.o bind.o chdir.o chmod.o \
gmtime.o ioctl.o itimer.o kill.o link.o listen.o lockf.o lseek.o mkdir.o \
mkfifo.o nice.o open.o opendir.o pause.o pipe.o read.o \
readdir.o readlink.o rename.o rewinddir.o rmdir.o select.o sendrecv.o \
setgid.o setuid.o shutdown.o sleep.o socket.o socketaddr.o \
setgid.o setsid.o setuid.o shutdown.o sleep.o socket.o socketaddr.o \
socketpair.o sockopt.o stat.o strofaddr.o symlink.o termios.o \
time.o times.o truncate.o umask.o unixsupport.o unlink.o \
utimes.o wait.o write.o

29
otherlibs/unix/setsid.c Normal file
View File

@ -0,0 +1,29 @@
/***********************************************************************/
/* */
/* Objective Caml */
/* */
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
/* */
/* Copyright 1997 Institut National de Recherche en Informatique et */
/* Automatique. Distributed only by permission. */
/* */
/***********************************************************************/
/* $Id$ */
#include <mlvalues.h>
#include "unixsupport.h"
#ifdef HAS_UNISTD
#include <unistd.h>
#endif
value unix_setsid(unit) /* ML */
value unit;
{
#ifdef HAS_SETSID
return Val_int(setsid());
#else
invalid_argument("setsid not implemented");
return Val_unit;
#endif
}

View File

@ -505,6 +505,8 @@ type flow_action = TCOOFF | TCOON | TCIOFF | TCION
external tcflow: file_descr -> flow_action -> unit = "unix_tcflow"
external setsid : unit -> int = "unix_setsid"
(* High-level process management (system, popen) *)
let system cmd =
@ -637,3 +639,4 @@ let establish_server server_fun sockaddr =
close_out outchan
| id -> close s; waitpid [] id (* Reclaim the son *); ()
done

View File

@ -175,7 +175,6 @@ external nice : int -> int = "unix_nice"
``nice'' value. (Higher values of the ``nice'' value mean
lower priorities.) Return the new nice value. *)
(*** Basic file input/output *)
type file_descr
@ -913,3 +912,7 @@ external tcflow: file_descr -> flow_action -> unit = "unix_tcflow"
[TCOOFF] suspends output, [TCOON] restarts output,
[TCIOFF] transmits a STOP character to suspend input,
and [TCION] transmits a START character to restart input. *)
external setsid : unit -> int = "unix_setsid"
(* Put the calling process in a new session and detach it from
its controlling terminal. *)