Override elf_nacl.xr linker script so that libc_pic.os links correctly
[glibc/nacl-glibc.git] / sysdeps / mach / hurd / fork.c
blob3288f186e5066b22323a30076d71da2a10f74074
1 /* Copyright (C) 1994,1995,1996,1997,1999,2001,2002,2004,2005,2006
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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #include <errno.h>
21 #include <unistd.h>
22 #include <hurd.h>
23 #include <hurd/signal.h>
24 #include <setjmp.h>
25 #include <thread_state.h>
26 #include <sysdep.h> /* For stack growth direction. */
27 #include "set-hooks.h"
28 #include <assert.h>
29 #include "hurdmalloc.h" /* XXX */
30 #include <tls.h>
32 #undef __fork
35 /* Things that want to be locked while forking. */
36 symbol_set_declare (_hurd_fork_locks)
39 /* Things that want to be called before we fork, to prepare the parent for
40 task_create, when the new child task will inherit our address space. */
41 DEFINE_HOOK (_hurd_fork_prepare_hook, (void));
43 /* Things that want to be called when we are forking, with the above all
44 locked. They are passed the task port of the child. The child process
45 is all set up except for doing proc_child, and has no threads yet. */
46 DEFINE_HOOK (_hurd_fork_setup_hook, (void));
48 /* Things to be run in the child fork. */
49 DEFINE_HOOK (_hurd_fork_child_hook, (void));
51 /* Things to be run in the parent fork. */
52 DEFINE_HOOK (_hurd_fork_parent_hook, (void));
55 /* Clone the calling process, creating an exact copy.
56 Return -1 for errors, 0 to the new process,
57 and the process ID of the new process to the old process. */
58 pid_t
59 __fork (void)
61 jmp_buf env;
62 pid_t pid;
63 size_t i;
64 error_t err;
65 struct hurd_sigstate *volatile ss;
67 ss = _hurd_self_sigstate ();
68 __spin_lock (&ss->critical_section_lock);
70 #undef LOSE
71 #define LOSE do { assert_perror (err); goto lose; } while (0) /* XXX */
73 if (! setjmp (env))
75 process_t newproc;
76 task_t newtask;
77 thread_t thread, sigthread;
78 mach_port_urefs_t thread_refs, sigthread_refs;
79 struct machine_thread_state state;
80 mach_msg_type_number_t statecount;
81 mach_port_t *portnames = NULL;
82 mach_msg_type_number_t nportnames = 0;
83 mach_port_type_t *porttypes = NULL;
84 mach_msg_type_number_t nporttypes = 0;
85 thread_t *threads = NULL;
86 mach_msg_type_number_t nthreads = 0;
87 int ports_locked = 0, stopped = 0;
89 void resume_threads (void)
91 if (! stopped)
92 return;
94 assert (threads);
96 for (i = 0; i < nthreads; ++i)
97 if (threads[i] != ss->thread)
98 __thread_resume (threads[i]);
99 stopped = 0;
102 /* Run things that prepare for forking before we create the task. */
103 RUN_HOOK (_hurd_fork_prepare_hook, ());
105 /* Lock things that want to be locked before we fork. */
107 void *const *p;
108 for (p = symbol_set_first_element (_hurd_fork_locks);
109 ! symbol_set_end_p (_hurd_fork_locks, p);
110 ++p)
111 __mutex_lock (*p);
113 __mutex_lock (&_hurd_siglock);
115 newtask = MACH_PORT_NULL;
116 thread = sigthread = MACH_PORT_NULL;
117 newproc = MACH_PORT_NULL;
119 /* Lock all the port cells for the standard ports while we copy the
120 address space. We want to insert all the send rights into the
121 child with the same names. */
122 for (i = 0; i < _hurd_nports; ++i)
123 __spin_lock (&_hurd_ports[i].lock);
124 ports_locked = 1;
127 /* Stop all other threads while copying the address space,
128 so nothing changes. */
129 err = __proc_dostop (_hurd_ports[INIT_PORT_PROC].port, ss->thread);
130 if (!err)
132 stopped = 1;
134 #define XXX_KERNEL_PAGE_FAULT_BUG /* XXX work around page fault bug in mk */
136 #ifdef XXX_KERNEL_PAGE_FAULT_BUG
137 /* Gag me with a pitchfork.
138 The bug scenario is this:
140 - The page containing __mach_task_self_ is paged out.
141 - The signal thread was faulting on that page when we
142 suspended it via proc_dostop. It holds some lock, or set
143 some busy bit, or somesuch.
144 - Now this thread faults on that same page.
145 - GRATUIOUS DEADLOCK
147 We can break the deadlock by aborting the thread that faulted
148 first, which if the bug happened was the signal thread because
149 it is the only other thread and we just suspended it.
151 __thread_abort (_hurd_msgport_thread);
152 #endif
153 /* Create the child task. It will inherit a copy of our memory. */
154 err = __task_create (__mach_task_self (),
155 #ifdef KERN_INVALID_LEDGER
156 NULL, 0, /* OSF Mach */
157 #endif
158 1, &newtask);
161 /* Unlock the global signal state lock, so we do not
162 block the signal thread any longer than necessary. */
163 __mutex_unlock (&_hurd_siglock);
165 if (err)
166 LOSE;
168 /* Fetch the names of all ports used in this task. */
169 if (err = __mach_port_names (__mach_task_self (),
170 &portnames, &nportnames,
171 &porttypes, &nporttypes))
172 LOSE;
173 if (nportnames != nporttypes)
175 err = EGRATUITOUS;
176 LOSE;
179 /* Get send rights for all the threads in this task.
180 We want to avoid giving these rights to the child. */
181 if (err = __task_threads (__mach_task_self (), &threads, &nthreads))
182 LOSE;
184 /* Get the child process's proc server port. We will insert it into
185 the child with the same name as we use for our own proc server
186 port; and we will need it to set the child's message port. */
187 if (err = __proc_task2proc (_hurd_ports[INIT_PORT_PROC].port,
188 newtask, &newproc))
189 LOSE;
191 /* Insert all our port rights into the child task. */
192 thread_refs = sigthread_refs = 0;
193 for (i = 0; i < nportnames; ++i)
195 if (porttypes[i] & MACH_PORT_TYPE_RECEIVE)
197 /* This is a receive right. We want to give the child task
198 its own new receive right under the same name. */
199 err = __mach_port_allocate_name (newtask,
200 MACH_PORT_RIGHT_RECEIVE,
201 portnames[i]);
202 if (err == KERN_NAME_EXISTS)
204 /* It already has a right under this name (?!). Well,
205 there is this bizarre old Mach IPC feature (in #ifdef
206 MACH_IPC_COMPAT in the ukernel) which results in new
207 tasks getting a new receive right for task special
208 port number 2. What else might be going on I'm not
209 sure. So let's check. */
210 #if !MACH_IPC_COMPAT
211 #define TASK_NOTIFY_PORT 2
212 #endif
213 assert (({ mach_port_t thisport, notify_port;
214 mach_msg_type_name_t poly;
215 (__task_get_special_port (newtask,
216 TASK_NOTIFY_PORT,
217 &notify_port) == 0 &&
218 __mach_port_extract_right
219 (newtask,
220 portnames[i],
221 MACH_MSG_TYPE_MAKE_SEND,
222 &thisport, &poly) == 0 &&
223 (thisport == notify_port) &&
224 __mach_port_deallocate (__mach_task_self (),
225 thisport) == 0 &&
226 __mach_port_deallocate (__mach_task_self (),
227 notify_port) == 0);
228 }));
230 else if (err)
231 LOSE;
232 if (porttypes[i] & MACH_PORT_TYPE_SEND)
234 /* Give the child as many send rights for its receive
235 right as we have for ours. */
236 mach_port_urefs_t refs;
237 mach_port_t port;
238 mach_msg_type_name_t poly;
239 if (err = __mach_port_get_refs (__mach_task_self (),
240 portnames[i],
241 MACH_PORT_RIGHT_SEND,
242 &refs))
243 LOSE;
244 if (err = __mach_port_extract_right (newtask,
245 portnames[i],
246 MACH_MSG_TYPE_MAKE_SEND,
247 &port, &poly))
248 LOSE;
249 if (portnames[i] == _hurd_msgport)
251 /* We just created a receive right for the child's
252 message port and are about to insert send rights
253 for it. Now, while we happen to have a send right
254 for it, give it to the proc server. */
255 mach_port_t old;
256 if (err = __proc_setmsgport (newproc, port, &old))
257 LOSE;
258 if (old != MACH_PORT_NULL)
259 /* XXX what to do here? */
260 __mach_port_deallocate (__mach_task_self (), old);
261 /* The new task will receive its own exceptions
262 on its message port. */
263 if (err =
264 #ifdef TASK_EXCEPTION_PORT
265 __task_set_special_port (newtask,
266 TASK_EXCEPTION_PORT,
267 port)
268 #elif defined (EXC_MASK_ALL)
269 __task_set_exception_ports
270 (newtask, EXC_MASK_ALL & ~(EXC_MASK_SYSCALL
271 | EXC_MASK_MACH_SYSCALL
272 | EXC_MASK_RPC_ALERT),
273 port, EXCEPTION_DEFAULT, MACHINE_THREAD_STATE)
274 #else
275 # error task_set_exception_port?
276 #endif
278 LOSE;
280 if (err = __mach_port_insert_right (newtask,
281 portnames[i],
282 port,
283 MACH_MSG_TYPE_MOVE_SEND))
284 LOSE;
285 if (refs > 1 &&
286 (err = __mach_port_mod_refs (newtask,
287 portnames[i],
288 MACH_PORT_RIGHT_SEND,
289 refs - 1)))
290 LOSE;
292 if (porttypes[i] & MACH_PORT_TYPE_SEND_ONCE)
294 /* Give the child a send-once right for its receive right,
295 since we have one for ours. */
296 mach_port_t port;
297 mach_msg_type_name_t poly;
298 if (err = __mach_port_extract_right
299 (newtask,
300 portnames[i],
301 MACH_MSG_TYPE_MAKE_SEND_ONCE,
302 &port, &poly))
303 LOSE;
304 if (err = __mach_port_insert_right
305 (newtask,
306 portnames[i], port,
307 MACH_MSG_TYPE_MOVE_SEND_ONCE))
308 LOSE;
311 else if (porttypes[i] &
312 (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_DEAD_NAME))
314 /* This is a send right or a dead name.
315 Give the child as many references for it as we have. */
316 mach_port_urefs_t refs, *record_refs = NULL;
317 mach_port_t insert;
318 mach_msg_type_name_t insert_type = MACH_MSG_TYPE_COPY_SEND;
319 if (portnames[i] == newtask || portnames[i] == newproc)
320 /* Skip the name we use for the child's task or proc ports. */
321 continue;
322 if (portnames[i] == __mach_task_self ())
323 /* For the name we use for our own task port,
324 insert the child's task port instead. */
325 insert = newtask;
326 else if (portnames[i] == _hurd_ports[INIT_PORT_PROC].port)
328 /* Use the proc server port for the new task. */
329 insert = newproc;
330 insert_type = MACH_MSG_TYPE_COPY_SEND;
332 else if (portnames[i] == ss->thread)
334 /* For the name we use for our own thread port, we will
335 insert the thread port for the child main user thread
336 after we create it. */
337 insert = MACH_PORT_NULL;
338 record_refs = &thread_refs;
339 /* Allocate a dead name right for this name as a
340 placeholder, so the kernel will not chose this name
341 for any other new port (it might use it for one of the
342 rights created when a thread is created). */
343 if (err = __mach_port_allocate_name
344 (newtask, MACH_PORT_RIGHT_DEAD_NAME, portnames[i]))
345 LOSE;
347 else if (portnames[i] == _hurd_msgport_thread)
348 /* For the name we use for our signal thread's thread port,
349 we will insert the thread port for the child's signal
350 thread after we create it. */
352 insert = MACH_PORT_NULL;
353 record_refs = &sigthread_refs;
354 /* Allocate a dead name right as a placeholder. */
355 if (err = __mach_port_allocate_name
356 (newtask, MACH_PORT_RIGHT_DEAD_NAME, portnames[i]))
357 LOSE;
359 else
361 /* Skip the name we use for any of our own thread ports. */
362 mach_msg_type_number_t j;
363 for (j = 0; j < nthreads; ++j)
364 if (portnames[i] == threads[j])
365 break;
366 if (j < nthreads)
367 continue;
369 /* Copy our own send right. */
370 insert = portnames[i];
372 /* Find out how many user references we have for
373 the send right with this name. */
374 if (err = __mach_port_get_refs (__mach_task_self (),
375 portnames[i],
376 MACH_PORT_RIGHT_SEND,
377 record_refs ?: &refs))
378 LOSE;
379 if (insert == MACH_PORT_NULL)
380 continue;
381 if (insert == portnames[i] &&
382 (porttypes[i] & MACH_PORT_TYPE_DEAD_NAME))
383 /* This is a dead name; allocate another dead name
384 with the same name in the child. */
385 allocate_dead_name:
386 err = __mach_port_allocate_name (newtask,
387 MACH_PORT_RIGHT_DEAD_NAME,
388 portnames[i]);
389 else
390 /* Insert the chosen send right into the child. */
391 err = __mach_port_insert_right (newtask,
392 portnames[i],
393 insert, insert_type);
394 switch (err)
396 case KERN_NAME_EXISTS:
398 /* It already has a send right under this name (?!).
399 Well, it starts out with a send right for its task
400 port, and inherits the bootstrap and exception ports
401 from us. */
402 mach_port_t childport;
403 mach_msg_type_name_t poly;
404 assert (__mach_port_extract_right (newtask, portnames[i],
405 MACH_MSG_TYPE_COPY_SEND,
406 &childport,
407 &poly) == 0 &&
408 childport == insert &&
409 __mach_port_deallocate (__mach_task_self (),
410 childport) == 0);
411 break;
414 case KERN_INVALID_CAPABILITY:
415 /* The port just died. It was a send right,
416 and now it's a dead name. */
417 goto allocate_dead_name;
419 default:
420 LOSE;
421 break;
423 case KERN_SUCCESS:
424 /* Give the child as many user references as we have. */
425 if (refs > 1 &&
426 (err = __mach_port_mod_refs (newtask,
427 portnames[i],
428 MACH_PORT_RIGHT_SEND,
429 refs - 1)))
430 LOSE;
435 /* Unlock the standard port cells. The child must unlock its own
436 copies too. */
437 for (i = 0; i < _hurd_nports; ++i)
438 __spin_unlock (&_hurd_ports[i].lock);
439 ports_locked = 0;
441 /* All state has now been copied from the parent. It is safe to
442 resume other parent threads. */
443 resume_threads ();
445 /* Create the child main user thread and signal thread. */
446 if ((err = __thread_create (newtask, &thread)) ||
447 (err = __thread_create (newtask, &sigthread)))
448 LOSE;
450 /* Insert send rights for those threads. We previously allocated
451 dead name rights with the names we want to give the thread ports
452 in the child as placeholders. Now deallocate them so we can use
453 the names. */
454 if ((err = __mach_port_deallocate (newtask, ss->thread)) ||
455 (err = __mach_port_insert_right (newtask, ss->thread,
456 thread, MACH_MSG_TYPE_COPY_SEND)))
457 LOSE;
458 /* We have one extra user reference created at the beginning of this
459 function, accounted for by mach_port_names (and which will thus be
460 accounted for in the child below). This extra right gets consumed
461 in the child by the store into _hurd_sigthread in the child fork. */
462 if (thread_refs > 1 &&
463 (err = __mach_port_mod_refs (newtask, ss->thread,
464 MACH_PORT_RIGHT_SEND,
465 thread_refs)))
466 LOSE;
467 if ((_hurd_msgport_thread != MACH_PORT_NULL) /* Let user have none. */
468 && ((err = __mach_port_deallocate (newtask, _hurd_msgport_thread)) ||
469 (err = __mach_port_insert_right (newtask, _hurd_msgport_thread,
470 sigthread,
471 MACH_MSG_TYPE_COPY_SEND))))
472 LOSE;
473 if (sigthread_refs > 1 &&
474 (err = __mach_port_mod_refs (newtask, _hurd_msgport_thread,
475 MACH_PORT_RIGHT_SEND,
476 sigthread_refs - 1)))
477 LOSE;
479 /* This seems like a convenient juncture to copy the proc server's
480 idea of what addresses our argv and envp are found at from the
481 parent into the child. Since we happen to know that the child
482 shares our memory image, it is we who should do this copying. */
484 vm_address_t argv, envp;
485 err = (__USEPORT (PROC, __proc_get_arg_locations (port, &argv, &envp))
486 ?: __proc_set_arg_locations (newproc, argv, envp));
487 if (err)
488 LOSE;
491 /* Set the child signal thread up to run the msgport server function
492 using the same signal thread stack copied from our address space.
493 We fetch the state before longjmp'ing it so that miscellaneous
494 registers not affected by longjmp (such as i386 segment registers)
495 are in their normal default state. */
496 statecount = MACHINE_THREAD_STATE_COUNT;
497 if (err = __thread_get_state (_hurd_msgport_thread,
498 MACHINE_THREAD_STATE_FLAVOR,
499 (natural_t *) &state, &statecount))
500 LOSE;
501 #if STACK_GROWTH_UP
502 #define THREADVAR_SPACE (__hurd_threadvar_max \
503 * sizeof *__hurd_sightread_variables)
504 if (__hurd_sigthread_stack_base == 0)
506 state.SP &= __hurd_threadvar_stack_mask;
507 state.SP += __hurd_threadvar_stack_offset + THREADVAR_SPACE;
509 else
510 state.SP = __hurd_sigthread_stack_base;
511 #else
512 if (__hurd_sigthread_stack_end == 0)
514 /* The signal thread has a normal stack assigned by cthreads.
515 The threadvar_stack variables conveniently tell us how
516 to get to the highest address in the stack, just below
517 the per-thread variables. */
518 state.SP &= __hurd_threadvar_stack_mask;
519 state.SP += __hurd_threadvar_stack_offset;
521 else
522 state.SP = __hurd_sigthread_stack_end;
523 #endif
524 MACHINE_THREAD_STATE_SET_PC (&state,
525 (unsigned long int) _hurd_msgport_receive);
526 if (err = __thread_set_state (sigthread, MACHINE_THREAD_STATE_FLAVOR,
527 (natural_t *) &state, statecount))
528 LOSE;
529 /* We do not thread_resume SIGTHREAD here because the child
530 fork needs to do more setup before it can take signals. */
532 /* Set the child user thread up to return 1 from the setjmp above. */
533 _hurd_longjmp_thread_state (&state, env, 1);
535 /* Do special thread setup for TLS if needed. */
536 if (err = _hurd_tls_fork (thread, &state))
537 LOSE;
539 if (err = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR,
540 (natural_t *) &state, statecount))
541 LOSE;
543 /* Get the PID of the child from the proc server. We must do this
544 before calling proc_child below, because at that point any
545 authorized POSIX.1 process may kill the child task with SIGKILL. */
546 if (err = __USEPORT (PROC, __proc_task2pid (port, newtask, &pid)))
547 LOSE;
549 /* Register the child with the proc server. It is important that
550 this be that last thing we do before starting the child thread
551 running. Once proc_child has been done for the task, it appears
552 as a POSIX.1 process. Any errors we get must be detected before
553 this point, and the child must have a message port so it responds
554 to POSIX.1 signals. */
555 if (err = __USEPORT (PROC, __proc_child (port, newtask)))
556 LOSE;
558 /* This must be the absolutely last thing we do; we can't assume that
559 the child will remain alive for even a moment once we do this. We
560 ignore errors because we have committed to the fork and are not
561 allowed to return them after the process becomes visible to
562 POSIX.1 (which happened right above when we called proc_child). */
563 (void) __thread_resume (thread);
565 lose:
566 if (ports_locked)
567 for (i = 0; i < _hurd_nports; ++i)
568 __spin_unlock (&_hurd_ports[i].lock);
570 resume_threads ();
572 if (newtask != MACH_PORT_NULL)
574 if (err)
575 __task_terminate (newtask);
576 __mach_port_deallocate (__mach_task_self (), newtask);
578 if (thread != MACH_PORT_NULL)
579 __mach_port_deallocate (__mach_task_self (), thread);
580 if (sigthread != MACH_PORT_NULL)
581 __mach_port_deallocate (__mach_task_self (), sigthread);
582 if (newproc != MACH_PORT_NULL)
583 __mach_port_deallocate (__mach_task_self (), newproc);
585 if (portnames)
586 __vm_deallocate (__mach_task_self (),
587 (vm_address_t) portnames,
588 nportnames * sizeof (*portnames));
589 if (porttypes)
590 __vm_deallocate (__mach_task_self (),
591 (vm_address_t) porttypes,
592 nporttypes * sizeof (*porttypes));
593 if (threads)
595 for (i = 0; i < nthreads; ++i)
596 __mach_port_deallocate (__mach_task_self (), threads[i]);
597 __vm_deallocate (__mach_task_self (),
598 (vm_address_t) threads,
599 nthreads * sizeof (*threads));
602 /* Run things that want to run in the parent to restore it to
603 normality. Usually prepare hooks and parent hooks are
604 symmetrical: the prepare hook arrests state in some way for the
605 fork, and the parent hook restores the state for the parent to
606 continue executing normally. */
607 RUN_HOOK (_hurd_fork_parent_hook, ());
609 else
611 struct hurd_sigstate *oldstates;
613 /* We are the child task. Unlock the standard port cells, which were
614 locked in the parent when we copied its memory. The parent has
615 inserted send rights with the names that were in the cells then. */
616 for (i = 0; i < _hurd_nports; ++i)
617 __spin_unlock (&_hurd_ports[i].lock);
619 /* We are one of the (exactly) two threads in this new task, we
620 will take the task-global signals. */
621 _hurd_sigthread = ss->thread;
623 /* Claim our sigstate structure and unchain the rest: the
624 threads existed in the parent task but don't exist in this
625 task (the child process). Delay freeing them until later
626 because some of the further setup and unlocking might be
627 required for free to work. Before we finish cleaning up,
628 we will reclaim the signal thread's sigstate structure (if
629 it had one). */
630 oldstates = _hurd_sigstates;
631 if (oldstates == ss)
632 oldstates = ss->next;
633 else
635 while (_hurd_sigstates->next != ss)
636 _hurd_sigstates = _hurd_sigstates->next;
637 _hurd_sigstates->next = ss->next;
639 ss->next = NULL;
640 _hurd_sigstates = ss;
641 __mutex_unlock (&_hurd_siglock);
643 /* Fetch our new process IDs from the proc server. No need to
644 refetch our pgrp; it is always inherited from the parent (so
645 _hurd_pgrp is already correct), and the proc server will send us a
646 proc_newids notification when it changes. */
647 err = __USEPORT (PROC, __proc_getpids (port, &_hurd_pid, &_hurd_ppid,
648 &_hurd_orphaned));
650 /* Forking clears the trace flag. */
651 __sigemptyset (&_hurdsig_traced);
653 /* Run things that want to run in the child task to set up. */
654 RUN_HOOK (_hurd_fork_child_hook, ());
656 /* Set up proc server-assisted fault recovery for the signal thread. */
657 _hurdsig_fault_init ();
659 /* Start the signal thread listening on the message port. */
660 if (!err)
661 err = __thread_resume (_hurd_msgport_thread);
663 /* Reclaim the signal thread's sigstate structure and free the
664 other old sigstate structures. */
665 while (oldstates != NULL)
667 struct hurd_sigstate *next = oldstates->next;
669 if (oldstates->thread == _hurd_msgport_thread)
671 /* If we have a second signal state structure then we
672 must have been through here before--not good. */
673 assert (_hurd_sigstates->next == 0);
674 _hurd_sigstates->next = oldstates;
675 oldstates->next = 0;
677 else
678 free (oldstates);
680 oldstates = next;
683 /* XXX what to do if we have any errors here? */
685 pid = 0;
688 /* Unlock things we locked before creating the child task.
689 They are locked in both the parent and child tasks. */
691 void *const *p;
692 for (p = symbol_set_first_element (_hurd_fork_locks);
693 ! symbol_set_end_p (_hurd_fork_locks, p);
694 ++p)
695 __mutex_unlock (*p);
698 _hurd_critical_section_unlock (ss);
700 return err ? __hurd_fail (err) : pid;
702 libc_hidden_def (__fork)
704 weak_alias (__fork, fork)