diff --git a/steam-runtime-tools/utils-internal.h b/steam-runtime-tools/utils-internal.h index bac38725eac9339f3896194400a25e1126f1b71d..ca463b8f548dc621b17c32a179afdefcafe7773c 100644 --- a/steam-runtime-tools/utils-internal.h +++ b/steam-runtime-tools/utils-internal.h @@ -30,6 +30,8 @@ typedef enum { + SRT_HELPER_FLAGS_TIME_OUT = (1 << 1), + SRT_HELPER_FLAGS_TIME_OUT_SOONER = (1 << 2), SRT_HELPER_FLAGS_NONE = 0 } SrtHelperFlags; diff --git a/steam-runtime-tools/utils.c b/steam-runtime-tools/utils.c index 3908dd4f920bd1e40497bcc9f9bcb3c9038bc728..3d8e1651eeeef491962545c9027a1906eedab5af 100644 --- a/steam-runtime-tools/utils.c +++ b/steam-runtime-tools/utils.c @@ -243,6 +243,27 @@ _srt_get_helper (const char *helpers_path, argv = g_ptr_array_new_with_free_func (g_free); + if (flags & SRT_HELPER_FLAGS_TIME_OUT) + { + g_ptr_array_add (argv, g_strdup ("timeout")); + g_ptr_array_add (argv, g_strdup ("--signal=TERM")); + + if (flags & SRT_HELPER_FLAGS_TIME_OUT_SOONER) + { + /* Speed up the failing case in automated testing */ + g_ptr_array_add (argv, g_strdup ("--kill-after=1")); + g_ptr_array_add (argv, g_strdup ("1")); + } + else + { + /* Kill the helper (if still running) 3 seconds after the TERM + * signal */ + g_ptr_array_add (argv, g_strdup ("--kill-after=3")); + /* Send TERM signal after 10 seconds */ + g_ptr_array_add (argv, g_strdup ("10")); + } + } + if (helpers_path == NULL) { helpers_path = _srt_get_helpers_path (error);