Skip to content

Commit ef4b30c

Browse files
committed
feat(console): Added session timeout and reports for login and logout
1 parent 339828f commit ef4b30c

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎system/cuos/dialog-maintenance.sh‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,19 @@ source "${SCRIPT_DIR}/dialog-keyboard.sh"
1111

1212

1313
session_timeout() {
14-
local timeout_seconds="$(jq_config '.console_session_timeout // ""')"
14+
local timeout_seconds
15+
timeout_seconds="$(jq_config '.console_session_timeout // ""')"
1516
timeout_seconds="${timeout_seconds:-"1800"}"
1617
export TIMEOUT_PID=""
1718

1819
# Run the command in background so trap can be checked
19-
"$@" &
20+
setsid "$0" "$@" &
2021
export CMD_PID=$!
22+
CMD_PGID="$(ps -o pgid= "${CMD_PID}" | tr -d ' ')"
23+
export CMD_PGID
2124

2225
# Start the timeout process
23-
(trap exit TERM; sleep "$timeout_seconds" & wait; echo "Timeout reached"; pkill -P "${CMD_PID}"; kill "${CMD_PID}") &
26+
(trap exit TERM; sleep "$timeout_seconds" & wait; echo "Timeout reached"; kill -- "-${CMD_PGID}") &
2427
TIMEOUT_PID=$!
2528

2629
cleanup() {

0 commit comments

Comments
 (0)