forked from UsergeTeam/Userge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
44 lines (36 loc) · 757 Bytes
/
run
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
39
40
41
42
43
44
#!/bin/bash
#
# Copyright (C) 2020-2021 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
#
# This file is part of < https://github.com/UsergeTeam/Userge > project,
# and is released under the "GNU v3.0 License Agreement".
# Please see < https://github.com/UsergeTeam/Userge/blob/master/LICENSE >
#
# All rights reserved.
trap joinProc INT TERM
declare -i bgProc
declare -ir usr1=138
declare -r cmd='. init/init.sh; runUserge "$@"'
setProc() {
bgProc=$1
}
waitProc() {
wait $bgProc
}
killProc() {
kill $bgProc &> /dev/null
}
joinProc() {
if test $bgProc; then
killProc
waitProc
fi
}
run() {
joinProc
bash -c "$cmd" $0 "$@" &
setProc $!
waitProc
test $? -eq $usr1 && run "$@"
}
run "$@"