Unix.setsid: guard against errors (#9958)

The return value of `setsid()` was not checked for errors.
master
Nicolás Ojeda Bär 2020-10-05 19:20:30 +02:00 committed by GitHub
parent e87b7ce437
commit 8806ddcbba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -292,6 +292,9 @@ Working version
(Ivan Gotovchits and Xavier Leroy, review by Sébastien Hinderer and
David Allsopp)
- #9958: Raise exception in case of error in Unix.setsid.
(Nicolás Ojeda Bär, review by Stephen Dolan)
### Tools:
- #9551: ocamlobjinfo is now able to display information on .cmxs shared

View File

@ -23,7 +23,9 @@
CAMLprim value unix_setsid(value unit)
{
#ifdef HAS_SETSID
return Val_int(setsid());
pid_t pid = setsid();
if (pid == (pid_t)(-1)) uerror("setsid", Nothing);
return Val_long(pid);
#else
caml_invalid_argument("setsid not implemented");
return Val_unit;