-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathchildren.functions
More file actions
38 lines (32 loc) · 1.3 KB
/
children.functions
File metadata and controls
38 lines (32 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# This file is part of shellfire core. It is subject to the licence terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/shellfire-dev/core/master/COPYRIGHT. No part of shellfire core, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
# Copyright © 2014-2015 The developers of shellfire core. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/shellfire-dev/core/master/COPYRIGHT.
core_usesIn core trap
core_usesIn core/variable array
core_children_initialise()
{
core_trap_addOnCleanUp core_children_killAll
}
core_functions_register _core_functions core_children_initialise
core_dependency_requires '*' kill
_core_children_killAll_callback()
{
local pid
for pid in "$@"
do
kill -TERM "$pid" 2>/dev/null || true
done
}
core_children_killAll()
{
if core_variable_array_isSet _core_children_childrenToRemoveOnExit; then
core_variable_array_passToFunctionAsArguments _core_children_childrenToRemoveOnExit _core_children_killAll_callback
fi
}
core_children_killOnExit()
{
local childPid
for childPid in "$@"
do
core_variable_array_append _core_children_childrenToRemoveOnExit "$childPid"
done
}