This is a wrapper around the _exit system call. It has been implemented
in otherlibs/unix/exit.c for a long time but never exported.
This commit exports and documents it as `Unix._exit`.
The Unix implementation of `establish_server` is changed to use `_exit`
and to have gender-neutral comments.
A test was added to check that OCaml finalization actions are not performed.
To preserve behaviour, explicit polls are added:
- in caml_raise, to raise the right exception when as system
call is interrupted by a signal.
- in sigprocmask, to ensure that signals are handled as soon
as they are unmasked.
This patch makes Unix.time and Unix.gettimeofday be unboxed and @noalloc, which makes them about 20% faster (as measured by a stupid benchmark that does them many times in a loop).
This removes the fallback and error-handling paths from gettimeofday. Neither is needed according to Single Unix Specification and POSIX.
Fixes: #7446
Unix.create_process was implemented in OCaml, using Unix.fork
and Unix.execvp. This commit reimplements it in C, for several reasons:
- The implementation can take advantage of posix_spawn, if available,
which is usually faster than fork + exec.
- The implementation is more atomic w.r.t. threading.
- Multicore OCaml will probably prohibit Unix.fork in multithreaded
programs.
The `execvpe` function is not always provided by C standard libraries.
PR #1414 implemented an emulation of `execvpe` in terms of `execve`
written in OCaml. This commit reimplements the emulation of `execvpe`
in C, so that it can be called from C. It implements exactly the same
algorithm, with one small change detailed next.
Small change: error ENAMETOOLONG stops the search instead of
continuing with the next entry in PATH. This seems more secure.
Some file systems maintain time stamps with sub-second resolution, up
to nanosecond resolution. When converting from a "(seconds, nanoseconds)"
timestamp to a floating-point timestamp, rounding to nearest can produce
"seconds + 1" as a result, i.e. the integer part of the FP timestamp
is not equal to "seconds". As described in #9490, this is a problem
in some cases.
This commit implements a more careful conversion of "(seconds,
nanoseconds)" pairs to FP timestamps so that the integer part of the
FP result is always "seconds".
Both the otherlibs/unix and the otherlibs/win32unix implementations are affected
and corrected.
Closes: #9490
When building for the first time, the only requirement is that generated
header files have been built (jumptbl.h, version.h and opnames.h).
Detailed dependency information is only required when headers have been
edited.
COMPUTE_DEPS in Makefile.config controls whether C dependency
information should be generated on a per-file basis. This variable is
controlled by a new --disable-dependency-generation in configure which
is enabled for Git checkouts and disabled for tarballs (i.e. releases).
The Microsoft C compiler (cl) cannot generate dependencies in a
consistent way which we can consume, so for a Git checkout configure
searches for an additional C compiler in order to compute dependencies.
This is obviously not required for a user-build.
As a result, the MSVC port can now safely run make alldepend, since only
OCaml dependency information is committed to the repo after this change.
CI does not need to waste time testing the dependency information,
because it only tests a single build. A single Travis job has been added
which tests the build system code to generate the dependency information
(and provides a single `make -j` run in CI, although Inria's CI also
tests parallel building continuously).
The instrumentation code in the instrumented runtime was replaced
with new APIs to gather runtime statistics and output them in a new format
(Common Trace Format).
This commit also exposes new functions in the Gc module to pause or resume
instrumentation during a program execution (Gc.eventlog_pause and
Gc.eventlog_resume).
A long time ago, an Internet hostname had only one IP address and
struct hostent had a member named h_addr pointing to one IP address.
Shortly after, the struct member h_addr became h_addr_list,
a NULL-terminated array of pointers to IP addresses, and many
standard headers contained `#define h_addr h_addr_list[0]`
for backward compatibility purposes.
In 2019, everyone has h_addr_list, and the #define h_addr is not mandated
by POSIX nor the Single Unix Specification. Hence, in strict
standard-conformance mode, h_addr is not there.
This commit makes sure h_addr_list is used everywhere and unconditionally.
The user can register several callbacks, which are called for various
events during the block's lifetime. We need to maintain a data
structure for tracked blocks in the runtime. When using threads,
callbacks can be called concurrently in a reentrant way, so the
functions manipulating this data structure need to be reentrant.
MPR#7672: add a Filename.quote_command function
This function takes care of quoting the command and its arguments
so that they are correctly parsed by the system shell
(/bin/sh for Unix, cmd.exe for Win32).
Redirections for std input (< file) and std output (> file) and
std error (2> file) can also be specified as optional arguments.
A 2>&1 redirection is used if stdout and stderr are redirected to the
same file.
The result is a string that can be passed directly to Sys.command or
to the Unix functions that expect shell command lines.