|
Packit |
6c4009 |
/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <hurd.h>
|
|
Packit |
6c4009 |
#include <lowlevellock.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
pid_t _hurd_pid, _hurd_ppid, _hurd_pgrp;
|
|
Packit |
6c4009 |
int _hurd_orphaned;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
static void
|
|
Packit |
6c4009 |
init_pids (void)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
__USEPORT (PROC,
|
|
Packit |
6c4009 |
({
|
|
Packit |
6c4009 |
__proc_getpids (port, &_hurd_pid, &_hurd_ppid, &_hurd_orphaned);
|
|
Packit |
6c4009 |
__proc_getpgrp (port, _hurd_pid, &_hurd_pgrp);
|
|
Packit |
6c4009 |
}));
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
(void) &init_pids; /* Avoid "defined but not used" warning. */
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
text_set_element (_hurd_proc_subinit, init_pids);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <hurd/msg_server.h>
|
|
Packit |
6c4009 |
#include "set-hooks.h"
|
|
Packit |
6c4009 |
#include <cthreads.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
DEFINE_HOOK (_hurd_pgrp_changed_hook, (pid_t));
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* These let user threads synchronize with an operation which changes ids. */
|
|
Packit |
6c4009 |
unsigned int _hurd_pids_changed_stamp;
|
|
Packit |
6c4009 |
struct condition _hurd_pids_changed_sync;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
kern_return_t
|
|
Packit |
6c4009 |
_S_msg_proc_newids (mach_port_t me,
|
|
Packit |
6c4009 |
task_t task,
|
|
Packit |
6c4009 |
pid_t ppid, pid_t pgrp, int orphaned)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
int pgrp_changed;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (task != __mach_task_self ())
|
|
Packit |
6c4009 |
return EPERM;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
__mach_port_deallocate (__mach_task_self (), task);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
pgrp_changed = pgrp != _hurd_pgrp;
|
|
Packit |
6c4009 |
_hurd_ppid = ppid;
|
|
Packit |
6c4009 |
_hurd_pgrp = pgrp;
|
|
Packit |
6c4009 |
_hurd_orphaned = orphaned;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (pgrp_changed)
|
|
Packit |
6c4009 |
/* Run things that want notification of a pgrp change. */
|
|
Packit |
6c4009 |
RUN_HOOK (_hurd_pgrp_changed_hook, (pgrp));
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Notify any waiting user threads that the id change as been completed. */
|
|
Packit |
6c4009 |
++_hurd_pids_changed_stamp;
|
|
Packit |
6c4009 |
lll_wake (&_hurd_pids_changed_stamp, GSYNC_BROADCAST);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
return 0;
|
|
Packit |
6c4009 |
}
|