···258258CAMLprim value eio_unix_fork_setpgid(value v_unit) {
259259 return Val_fork_fn(action_setpgid);
260260}
261261+262262+static void action_setuid(int errors, value v_config) {
263263+ #ifdef _WIN32
264264+ eio_unix_fork_error(errors, "action_setuid", "Unsupported operation on windows");
265265+ _exit(1);
266266+ #else
267267+ value v_uid = Field(v_config, 1);
268268+ int r;
269269+ r = setuid(Int_val(v_uid));
270270+ if (r != 0) {
271271+ eio_unix_fork_error(errors, "setuid", strerror(errno));
272272+ _exit(1);
273273+ }
274274+ #endif
275275+}
276276+277277+CAMLprim value eio_unix_fork_setuid(value v_unit) {
278278+ return Val_fork_fn(action_setuid);
279279+}
280280+281281+static void action_setgid(int errors, value v_config) {
282282+ #ifdef _WIN32
283283+ eio_unix_fork_error(errors, "action_setgid", "Unsupported operation on windows");
284284+ _exit(1);
285285+ #else
286286+ value v_gid = Field(v_config, 1);
287287+ int r;
288288+ r = setgid(Int_val(v_gid));
289289+ if (r != 0) {
290290+ eio_unix_fork_error(errors, "setgid", strerror(errno));
291291+ _exit(1);
292292+ }
293293+ #endif
294294+}
295295+296296+CAMLprim value eio_unix_fork_setgid(value v_unit) {
297297+ return Val_fork_fn(action_setgid);
298298+}
+10-1
vendor/opam/eio/lib_eio/unix/fork_action.ml
···71717272external action_setpgid : unit -> fork_fn = "eio_unix_fork_setpgid"
7373let action_setpgid = action_setpgid ()
7474-7574let setpgid pgid =
7675 { run = fun k -> k (Obj.repr (action_setpgid, 0, pgid)) }
7676+7777+external action_setuid : unit -> fork_fn = "eio_unix_fork_setuid"
7878+let action_setuid = action_setuid ()
7979+let setuid uid = {
8080+ run = fun k -> k (Obj.repr (action_setuid, uid)) }
8181+8282+external action_setgid : unit -> fork_fn = "eio_unix_fork_setgid"
8383+let action_setgid = action_setgid ()
8484+let setgid gid = {
8585+ run = fun k -> k (Obj.repr (action_setgid, gid)) }
+6
vendor/opam/eio/lib_eio/unix/fork_action.mli
···64646565 If [pgid] is [0] the child's process ID will be used as the PGID, placing
6666 the child in a {e new} process group. *)
6767+6868+val setuid : int -> t
6969+(** [setuid uid] sets the user ID to [uid]. *)
7070+7171+val setgid : int -> t
7272+(** [setgid gid] sets the group ID to [gid]. *)