From 40d6f19ff9c1d052c860365a98a8a074d5671142 Mon Sep 17 00:00:00 2001 From: Imre Deak Date: Fri, 13 Oct 2017 14:30:08 +0300 Subject: aux: Suspend signal helper for shell commands The clone() system call with a larger executable (like /bin/sh) may have difficulty to make progress on some platforms if interrupted frequently. So suspend the signal helper process for the duration of the syscall. This is needed to solve an actual problem by the next patch. v2: - Clarify/fix code comments. (Chris) - Update igt_system_quiet() as well accordingly. Cc: Chris Wilson Cc: Daniel Vetter Signed-off-by: Imre Deak Reviewed-by: Chris Wilson (v1) --- lib/igt_core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib/igt_core.c') diff --git a/lib/igt_core.c b/lib/igt_core.c index 950ea9b0..538a4472 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -2282,6 +2282,13 @@ int igt_system(const char *command) if (pipe(errpipe) < 0) goto err; + /* + * The clone() system call called from a largish executable has + * difficulty to make progress if interrupted too frequently, so + * suspend the signal helper for the time of the syscall. + */ + igt_suspend_signal_helper(); + igt_fork_helper(&process) { close(outpipe[0]); close(errpipe[0]); @@ -2298,6 +2305,8 @@ int igt_system(const char *command) exit(EXIT_FAILURE); } + igt_resume_signal_helper(); + close(outpipe[1]); close(errpipe[1]); @@ -2340,9 +2349,14 @@ int igt_system_quiet(const char *command) if (dup2(nullfd, STDERR_FILENO) == -1) goto err; + /* See igt_system() for the reason for suspending the signal helper. */ + igt_suspend_signal_helper(); + if ((status = system(command)) == -1) goto err; + igt_resume_signal_helper(); + /* restore */ if (dup2(stdout_fd_copy, STDOUT_FILENO) == -1) goto err; @@ -2355,6 +2369,8 @@ int igt_system_quiet(const char *command) return WEXITSTATUS(status); err: + igt_resume_signal_helper(); + close(stderr_fd_copy); close(stdout_fd_copy); close(nullfd); -- cgit v1.2.3