Replace FSF snail mail address with URLs.
[glibc.git] / sysdeps / mach / hurd / fork.c
blob644838cd9c5b8172ce08a683ad096e060c5a2ed5
1 /* Copyright (C) 1994,1995,1996,1997,1999,2001,2002,2004,2005,2006,2011
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <errno.h>
20 #include <unistd.h>
21 #include <hurd.h>
22 #include <hurd/signal.h>
23 #include <setjmp.h>
24 #include <thread_state.h>
25 #include <sysdep.h> /* For stack growth direction. */
26 #include "set-hooks.h"
27 #include <assert.h>
28 #include "hurdmalloc.h" /* XXX */
29 #include <tls.h>
31 #undef __fork
34 /* Things that want to be locked while forking. */
35 symbol_set_declare (_hurd_fork_locks)
38 /* Things that want to be called before we fork, to prepare the parent for
39 task_create, when the new child task will inherit our address space. */
40 DEFINE_HOOK (_hurd_fork_prepare_hook, (void));
42 /* Things that want to be called when we are forking, with the above all
43 locked. They are passed the task port of the child. The child process
44 is all set up except for doing proc_child, and has no threads yet. */
45 DEFINE_HOOK (_hurd_fork_setup_hook, (void));
47 /* Things to be run in the child fork. */
48 DEFINE_HOOK (_hurd_fork_child_hook, (void));
50 /* Things to be run in the parent fork. */
51 DEFINE_HOOK (_hurd_fork_parent_hook, (void));
54 /* Clone the calling process, creating an exact copy.
55 Return -1 for errors, 0 to the new process,
56 and the process ID of the new process to the old process. */
57 pid_t
58 __fork (void)
60 jmp_buf env;
61 pid_t pid;
62 size_t i;
63 error_t err;
64 struct hurd_sigstate *volatile ss;
66 ss = _hurd_self_sigstate ();
67 __spin_lock (&ss->critical_section_lock);
69 #undef LOSE
70 #define LOSE do { assert_perror (err); goto lose; } while (0) /* XXX */
72 if (! setjmp (env))
74 process_t newproc;
75 task_t newtask;
76 thread_t thread, sigthread;
77 mach_port_urefs_t thread_refs, sigthread_refs;
78 struct machine_thread_state state;
79 mach_msg_type_number_t statecount;
80 mach_port_t *portnames = NULL;
81 mach_msg_type_number_t nportnames = 0;
82 mach_port_type_t *porttypes = NULL;
83 mach_msg_type_number_t nporttypes = 0;
84 thread_t *threads = NULL;
85 mach_msg_type_number_t nthreads = 0;
86 int ports_locked = 0, stopped = 0;
88 void resume_threads (void)
90 if (! stopped)
91 return;
93 assert (threads);
95 for (i = 0; i < nthreads; ++i)
96 if (threads[i] != ss->thread)
97 __thread_resume (threads[i]);
98 stopped = 0;
101 /* Run things that prepare for forking before we create the task. */
102 RUN_HOOK (_hurd_fork_prepare_hook, ());
104 /* Lock things that want to be locked before we fork. */
106 void *const *p;
107 for (p = symbol_set_first_element (_hurd_fork_locks);
108 ! symbol_set_end_p (_hurd_fork_locks, p);
109 ++p)
110 __mutex_lock (*p);
112 __mutex_lock (&_hurd_siglock);
114 newtask = MACH_PORT_NULL;
115 thread = sigthread = MACH_PORT_NULL;
116 newproc = MACH_PORT_NULL;
118 /* Lock all the port cells for the standard ports while we copy the
119 address space. We want to insert all the send rights into the
120 child with the same names. */
121 for (i = 0; i < _hurd_nports; ++i)
122 __spin_lock (&_hurd_ports[i].lock);
123 ports_locked = 1;
126 /* Stop all other threads while copying the address space,
127 so nothing changes. */
128 err = __proc_dostop (_hurd_ports[INIT_PORT_PROC].port, ss->thread);
129 if (!err)
131 stopped = 1;
133 #define XXX_KERNEL_PAGE_FAULT_BUG /* XXX work around page fault bug in mk */
135 #ifdef XXX_KERNEL_PAGE_FAULT_BUG
136 /* Gag me with a pitchfork.
137 The bug scenario is this:
139 - The page containing __mach_task_self_ is paged out.
140 - The signal thread was faulting on that page when we
141 suspended it via proc_dostop. It holds some lock, or set
142 some busy bit, or somesuch.
143 - Now this thread faults on that same page.
144 - GRATUIOUS DEADLOCK
146 We can break the deadlock by aborting the thread that faulted
147 first, which if the bug happened was the signal thread because
148 it is the only other thread and we just suspended it.
150 __thread_abort (_hurd_msgport_thread);
151 #endif
152 /* Create the child task. It will inherit a copy of our memory. */
153 err = __task_create (__mach_task_self (),
154 #ifdef KERN_INVALID_LEDGER
155 NULL, 0, /* OSF Mach */
156 #endif
157 1, &newtask);
160 /* Unlock the global signal state lock, so we do not
161 block the signal thread any longer than necessary. */
162 __mutex_unlock (&_hurd_siglock);
164 if (err)
165 LOSE;
167 /* Fetch the names of all ports used in this task. */
168 if (err = __mach_port_names (__mach_task_self (),
169 &portnames, &nportnames,
170 &porttypes, &nporttypes))
171 LOSE;
172 if (nportnames != nporttypes)
174 err = EGRATUITOUS;
175 LOSE;
178 /* Get send rights for all the threads in this task.
179 We want to avoid giving these rights to the child. */
180 if (err = __task_threads (__mach_task_self (), &threads, &nthreads))
181 LOSE;
183 /* Get the child process's proc server port. We will insert it into
184 the child with the same name as we use for our own proc server
185 port; and we will need it to set the child's message port. */
186 if (err = __proc_task2proc (_hurd_ports[INIT_PORT_PROC].port,
187 newtask, &newproc))
188 LOSE;
190 /* Insert all our port rights into the child task. */
191 thread_refs = sigthread_refs = 0;
192 for (i = 0; i < nportnames; ++i)
194 if (porttypes[i] & MACH_PORT_TYPE_RECEIVE)
196 /* This is a receive right. We want to give the child task
197 its own new receive right under the same name. */
198 err = __mach_port_allocate_name (newtask,
199 MACH_PORT_RIGHT_RECEIVE,
200 portnames[i]);
201 if (err == KERN_NAME_EXISTS)
203 /* It already has a right under this name (?!). Well,
204 there is this bizarre old Mach IPC feature (in #ifdef
205 MACH_IPC_COMPAT in the ukernel) which results in new
206 tasks getting a new receive right for task special
207 port number 2. What else might be going on I'm not
208 sure. So let's check. */
209 #if !MACH_IPC_COMPAT
210 #define TASK_NOTIFY_PORT 2
211 #endif
212 assert (({ mach_port_t thisport, notify_port;
213 mach_msg_type_name_t poly;
214 (__task_get_special_port (newtask,
215 TASK_NOTIFY_PORT,
216 &notify_port) == 0 &&
217 __mach_port_extract_right
218 (newtask,
219 portnames[i],
220 MACH_MSG_TYPE_MAKE_SEND,
221 &thisport, &poly) == 0 &&
222 (thisport == notify_port) &&
223 __mach_port_deallocate (__mach_task_self (),
224 thisport) == 0 &&
225 __mach_port_deallocate (__mach_task_self (),
226 notify_port) == 0);
227 }));
229 else if (err)
230 LOSE;
231 if (porttypes[i] & MACH_PORT_TYPE_SEND)
233 /* Give the child as many send rights for its receive
234 right as we have for ours. */
235 mach_port_urefs_t refs;
236 mach_port_t port;
237 mach_msg_type_name_t poly;
238 if (err = __mach_port_get_refs (__mach_task_self (),
239 portnames[i],
240 MACH_PORT_RIGHT_SEND,
241 &refs))
242 LOSE;
243 if (err = __mach_port_extract_right (newtask,
244 portnames[i],
245 MACH_MSG_TYPE_MAKE_SEND,
246 &port, &poly))
247 LOSE;
248 if (portnames[i] == _hurd_msgport)
250 /* We just created a receive right for the child's
251 message port and are about to insert send rights
252 for it. Now, while we happen to have a send right
253 for it, give it to the proc server. */
254 mach_port_t old;
255 if (err = __proc_setmsgport (newproc, port, &old))
256 LOSE;
257 if (old != MACH_PORT_NULL)
258 /* XXX what to do here? */
259 __mach_port_deallocate (__mach_task_self (), old);
260 /* The new task will receive its own exceptions
261 on its message port. */
262 if (err =
263 #ifdef TASK_EXCEPTION_PORT
264 __task_set_special_port (newtask,
265 TASK_EXCEPTION_PORT,
266 port)
267 #elif defined (EXC_MASK_ALL)
268 __task_set_exception_ports
269 (newtask, EXC_MASK_ALL & ~(EXC_MASK_SYSCALL
270 | EXC_MASK_MACH_SYSCALL
271 | EXC_MASK_RPC_ALERT),
272 port, EXCEPTION_DEFAULT, MACHINE_THREAD_STATE)
273 #else
274 # error task_set_exception_port?
275 #endif
277 LOSE;
279 if (err = __mach_port_insert_right (newtask,
280 portnames[i],
281 port,
282 MACH_MSG_TYPE_MOVE_SEND))
283 LOSE;
284 if (refs > 1 &&
285 (err = __mach_port_mod_refs (newtask,
286 portnames[i],
287 MACH_PORT_RIGHT_SEND,
288 refs - 1)))
289 LOSE;
291 if (porttypes[i] & MACH_PORT_TYPE_SEND_ONCE)
293 /* Give the child a send-once right for its receive right,
294 since we have one for ours. */
295 mach_port_t port;
296 mach_msg_type_name_t poly;
297 if (err = __mach_port_extract_right
298 (newtask,
299 portnames[i],
300 MACH_MSG_TYPE_MAKE_SEND_ONCE,
301 &port, &poly))
302 LOSE;
303 if (err = __mach_port_insert_right
304 (newtask,
305 portnames[i], port,
306 MACH_MSG_TYPE_MOVE_SEND_ONCE))
307 LOSE;
310 else if (porttypes[i] &
311 (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_DEAD_NAME))
313 /* This is a send right or a dead name.
314 Give the child as many references for it as we have. */
315 mach_port_urefs_t refs = 0, *record_refs = NULL;
316 mach_port_t insert;
317 mach_msg_type_name_t insert_type = MACH_MSG_TYPE_COPY_SEND;
318 if (portnames[i] == newtask || portnames[i] == newproc)
319 /* Skip the name we use for the child's task or proc ports. */
320 continue;
321 if (portnames[i] == __mach_task_self ())
322 /* For the name we use for our own task port,
323 insert the child's task port instead. */
324 insert = newtask;
325 else if (portnames[i] == _hurd_ports[INIT_PORT_PROC].port)
327 /* Use the proc server port for the new task. */
328 insert = newproc;
329 insert_type = MACH_MSG_TYPE_COPY_SEND;
331 else if (portnames[i] == ss->thread)
333 /* For the name we use for our own thread port, we will
334 insert the thread port for the child main user thread
335 after we create it. */
336 insert = MACH_PORT_NULL;
337 record_refs = &thread_refs;
338 /* Allocate a dead name right for this name as a
339 placeholder, so the kernel will not chose this name
340 for any other new port (it might use it for one of the
341 rights created when a thread is created). */
342 if (err = __mach_port_allocate_name
343 (newtask, MACH_PORT_RIGHT_DEAD_NAME, portnames[i]))
344 LOSE;
346 else if (portnames[i] == _hurd_msgport_thread)
347 /* For the name we use for our signal thread's thread port,
348 we will insert the thread port for the child's signal
349 thread after we create it. */
351 insert = MACH_PORT_NULL;
352 record_refs = &sigthread_refs;
353 /* Allocate a dead name right as a placeholder. */
354 if (err = __mach_port_allocate_name
355 (newtask, MACH_PORT_RIGHT_DEAD_NAME, portnames[i]))
356 LOSE;
358 else
360 /* Skip the name we use for any of our own thread ports. */
361 mach_msg_type_number_t j;
362 for (j = 0; j < nthreads; ++j)
363 if (portnames[i] == threads[j])
364 break;
365 if (j < nthreads)
366 continue;
368 /* Copy our own send right. */
369 insert = portnames[i];
371 /* Find out how many user references we have for
372 the send right with this name. */
373 if (err = __mach_port_get_refs (__mach_task_self (),
374 portnames[i],
375 MACH_PORT_RIGHT_SEND,
376 record_refs ?: &refs))
377 LOSE;
378 if (insert == MACH_PORT_NULL)
379 continue;
380 if (insert == portnames[i] &&
381 (porttypes[i] & MACH_PORT_TYPE_DEAD_NAME))
382 /* This is a dead name; allocate another dead name
383 with the same name in the child. */
384 allocate_dead_name:
385 err = __mach_port_allocate_name (newtask,
386 MACH_PORT_RIGHT_DEAD_NAME,
387 portnames[i]);
388 else
389 /* Insert the chosen send right into the child. */
390 err = __mach_port_insert_right (newtask,
391 portnames[i],
392 insert, insert_type);
393 switch (err)
395 case KERN_NAME_EXISTS:
397 /* It already has a send right under this name (?!).
398 Well, it starts out with a send right for its task
399 port, and inherits the bootstrap and exception ports
400 from us. */
401 mach_port_t childport;
402 mach_msg_type_name_t poly;
403 assert (__mach_port_extract_right (newtask, portnames[i],
404 MACH_MSG_TYPE_COPY_SEND,
405 &childport,
406 &poly) == 0 &&
407 childport == insert &&
408 __mach_port_deallocate (__mach_task_self (),
409 childport) == 0);
410 break;
413 case KERN_INVALID_CAPABILITY:
414 /* The port just died. It was a send right,
415 and now it's a dead name. */
416 goto allocate_dead_name;
418 default:
419 LOSE;
420 break;
422 case KERN_SUCCESS:
423 /* Give the child as many user references as we have. */
424 if (refs > 1 &&
425 (err = __mach_port_mod_refs (newtask,
426 portnames[i],
427 MACH_PORT_RIGHT_SEND,
428 refs - 1)))
429 LOSE;
434 /* Unlock the standard port cells. The child must unlock its own
435 copies too. */
436 for (i = 0; i < _hurd_nports; ++i)
437 __spin_unlock (&_hurd_ports[i].lock);
438 ports_locked = 0;
440 /* All state has now been copied from the parent. It is safe to
441 resume other parent threads. */
442 resume_threads ();
444 /* Create the child main user thread and signal thread. */
445 if ((err = __thread_create (newtask, &thread)) ||
446 (err = __thread_create (newtask, &sigthread)))
447 LOSE;
449 /* Insert send rights for those threads. We previously allocated
450 dead name rights with the names we want to give the thread ports
451 in the child as placeholders. Now deallocate them so we can use
452 the names. */
453 if ((err = __mach_port_deallocate (newtask, ss->thread)) ||
454 (err = __mach_port_insert_right (newtask, ss->thread,
455 thread, MACH_MSG_TYPE_COPY_SEND)))
456 LOSE;
457 /* We have one extra user reference created at the beginning of this
458 function, accounted for by mach_port_names (and which will thus be
459 accounted for in the child below). This extra right gets consumed
460 in the child by the store into _hurd_sigthread in the child fork. */
461 if (thread_refs > 1 &&
462 (err = __mach_port_mod_refs (newtask, ss->thread,
463 MACH_PORT_RIGHT_SEND,
464 thread_refs)))
465 LOSE;
466 if ((_hurd_msgport_thread != MACH_PORT_NULL) /* Let user have none. */
467 && ((err = __mach_port_deallocate (newtask, _hurd_msgport_thread)) ||
468 (err = __mach_port_insert_right (newtask, _hurd_msgport_thread,
469 sigthread,
470 MACH_MSG_TYPE_COPY_SEND))))
471 LOSE;
472 if (sigthread_refs > 1 &&
473 (err = __mach_port_mod_refs (newtask, _hurd_msgport_thread,
474 MACH_PORT_RIGHT_SEND,
475 sigthread_refs - 1)))
476 LOSE;
478 /* This seems like a convenient juncture to copy the proc server's
479 idea of what addresses our argv and envp are found at from the
480 parent into the child. Since we happen to know that the child
481 shares our memory image, it is we who should do this copying. */
483 vm_address_t argv, envp;
484 err = (__USEPORT (PROC, __proc_get_arg_locations (port, &argv, &envp))
485 ?: __proc_set_arg_locations (newproc, argv, envp));
486 if (err)
487 LOSE;
490 /* Set the child signal thread up to run the msgport server function
491 using the same signal thread stack copied from our address space.
492 We fetch the state before longjmp'ing it so that miscellaneous
493 registers not affected by longjmp (such as i386 segment registers)
494 are in their normal default state. */
495 statecount = MACHINE_THREAD_STATE_COUNT;
496 if (err = __thread_get_state (_hurd_msgport_thread,
497 MACHINE_THREAD_STATE_FLAVOR,
498 (natural_t *) &state, &statecount))
499 LOSE;
500 #if STACK_GROWTH_UP
501 #define THREADVAR_SPACE (__hurd_threadvar_max \
502 * sizeof *__hurd_sightread_variables)
503 if (__hurd_sigthread_stack_base == 0)
505 state.SP &= __hurd_threadvar_stack_mask;
506 state.SP += __hurd_threadvar_stack_offset + THREADVAR_SPACE;
508 else
509 state.SP = __hurd_sigthread_stack_base;
510 #else
511 if (__hurd_sigthread_stack_end == 0)
513 /* The signal thread has a normal stack assigned by cthreads.
514 The threadvar_stack variables conveniently tell us how
515 to get to the highest address in the stack, just below
516 the per-thread variables. */
517 state.SP &= __hurd_threadvar_stack_mask;
518 state.SP += __hurd_threadvar_stack_offset;
520 else
521 state.SP = __hurd_sigthread_stack_end;
522 #endif
523 MACHINE_THREAD_STATE_SET_PC (&state,
524 (unsigned long int) _hurd_msgport_receive);
525 if (err = __thread_set_state (sigthread, MACHINE_THREAD_STATE_FLAVOR,
526 (natural_t *) &state, statecount))
527 LOSE;
528 /* We do not thread_resume SIGTHREAD here because the child
529 fork needs to do more setup before it can take signals. */
531 /* Set the child user thread up to return 1 from the setjmp above. */
532 _hurd_longjmp_thread_state (&state, env, 1);
534 /* Do special thread setup for TLS if needed. */
535 if (err = _hurd_tls_fork (thread, &state))
536 LOSE;
538 if (err = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR,
539 (natural_t *) &state, statecount))
540 LOSE;
542 /* Get the PID of the child from the proc server. We must do this
543 before calling proc_child below, because at that point any
544 authorized POSIX.1 process may kill the child task with SIGKILL. */
545 if (err = __USEPORT (PROC, __proc_task2pid (port, newtask, &pid)))
546 LOSE;
548 /* Register the child with the proc server. It is important that
549 this be that last thing we do before starting the child thread
550 running. Once proc_child has been done for the task, it appears
551 as a POSIX.1 process. Any errors we get must be detected before
552 this point, and the child must have a message port so it responds
553 to POSIX.1 signals. */
554 if (err = __USEPORT (PROC, __proc_child (port, newtask)))
555 LOSE;
557 /* This must be the absolutely last thing we do; we can't assume that
558 the child will remain alive for even a moment once we do this. We
559 ignore errors because we have committed to the fork and are not
560 allowed to return them after the process becomes visible to
561 POSIX.1 (which happened right above when we called proc_child). */
562 (void) __thread_resume (thread);
564 lose:
565 if (ports_locked)
566 for (i = 0; i < _hurd_nports; ++i)
567 __spin_unlock (&_hurd_ports[i].lock);
569 resume_threads ();
571 if (newtask != MACH_PORT_NULL)
573 if (err)
574 __task_terminate (newtask);
575 __mach_port_deallocate (__mach_task_self (), newtask);
577 if (thread != MACH_PORT_NULL)
578 __mach_port_deallocate (__mach_task_self (), thread);
579 if (sigthread != MACH_PORT_NULL)
580 __mach_port_deallocate (__mach_task_self (), sigthread);
581 if (newproc != MACH_PORT_NULL)
582 __mach_port_deallocate (__mach_task_self (), newproc);
584 if (portnames)
585 __vm_deallocate (__mach_task_self (),
586 (vm_address_t) portnames,
587 nportnames * sizeof (*portnames));
588 if (porttypes)
589 __vm_deallocate (__mach_task_self (),
590 (vm_address_t) porttypes,
591 nporttypes * sizeof (*porttypes));
592 if (threads)
594 for (i = 0; i < nthreads; ++i)
595 __mach_port_deallocate (__mach_task_self (), threads[i]);
596 __vm_deallocate (__mach_task_self (),
597 (vm_address_t) threads,
598 nthreads * sizeof (*threads));
601 /* Run things that want to run in the parent to restore it to
602 normality. Usually prepare hooks and parent hooks are
603 symmetrical: the prepare hook arrests state in some way for the
604 fork, and the parent hook restores the state for the parent to
605 continue executing normally. */
606 RUN_HOOK (_hurd_fork_parent_hook, ());
608 else
610 struct hurd_sigstate *oldstates;
612 /* We are the child task. Unlock the standard port cells, which were
613 locked in the parent when we copied its memory. The parent has
614 inserted send rights with the names that were in the cells then. */
615 for (i = 0; i < _hurd_nports; ++i)
616 __spin_unlock (&_hurd_ports[i].lock);
618 /* We are one of the (exactly) two threads in this new task, we
619 will take the task-global signals. */
620 _hurd_sigthread = ss->thread;
622 /* Claim our sigstate structure and unchain the rest: the
623 threads existed in the parent task but don't exist in this
624 task (the child process). Delay freeing them until later
625 because some of the further setup and unlocking might be
626 required for free to work. Before we finish cleaning up,
627 we will reclaim the signal thread's sigstate structure (if
628 it had one). */
629 oldstates = _hurd_sigstates;
630 if (oldstates == ss)
631 oldstates = ss->next;
632 else
634 while (_hurd_sigstates->next != ss)
635 _hurd_sigstates = _hurd_sigstates->next;
636 _hurd_sigstates->next = ss->next;
638 ss->next = NULL;
639 _hurd_sigstates = ss;
640 __mutex_unlock (&_hurd_siglock);
642 /* Fetch our new process IDs from the proc server. No need to
643 refetch our pgrp; it is always inherited from the parent (so
644 _hurd_pgrp is already correct), and the proc server will send us a
645 proc_newids notification when it changes. */
646 err = __USEPORT (PROC, __proc_getpids (port, &_hurd_pid, &_hurd_ppid,
647 &_hurd_orphaned));
649 /* Forking clears the trace flag. */
650 __sigemptyset (&_hurdsig_traced);
652 /* Run things that want to run in the child task to set up. */
653 RUN_HOOK (_hurd_fork_child_hook, ());
655 /* Set up proc server-assisted fault recovery for the signal thread. */
656 _hurdsig_fault_init ();
658 /* Start the signal thread listening on the message port. */
659 if (!err)
660 err = __thread_resume (_hurd_msgport_thread);
662 /* Reclaim the signal thread's sigstate structure and free the
663 other old sigstate structures. */
664 while (oldstates != NULL)
666 struct hurd_sigstate *next = oldstates->next;
668 if (oldstates->thread == _hurd_msgport_thread)
670 /* If we have a second signal state structure then we
671 must have been through here before--not good. */
672 assert (_hurd_sigstates->next == 0);
673 _hurd_sigstates->next = oldstates;
674 oldstates->next = 0;
676 else
677 free (oldstates);
679 oldstates = next;
682 /* XXX what to do if we have any errors here? */
684 pid = 0;
687 /* Unlock things we locked before creating the child task.
688 They are locked in both the parent and child tasks. */
690 void *const *p;
691 for (p = symbol_set_first_element (_hurd_fork_locks);
692 ! symbol_set_end_p (_hurd_fork_locks, p);
693 ++p)
694 __mutex_unlock (*p);
697 _hurd_critical_section_unlock (ss);
699 return err ? __hurd_fail (err) : pid;
701 libc_hidden_def (__fork)
703 weak_alias (__fork, fork)