[10/12] compel/infect: Detach but fail compel_resume_task()

Submitted by Dmitry Safonov on Nov. 9, 2019, 10:20 p.m.

Details

Message ID 20191109222045.89507-11-dima@arista.com
State Accepted
Series "compel: Add __must_check"
Commit 4d36e0d5b1f78dcb99e3caa6aa5dc00dd3e45e70
Headers show

Commit Message

Dmitry Safonov Nov. 9, 2019, 10:20 p.m.
Unknown state means that the task in the end may be not in wanted state.
Return err code.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 compel/src/lib/infect.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/compel/src/lib/infect.c b/compel/src/lib/infect.c
index 8b377e7d22d8..3fad85ed3c8f 100644
--- a/compel/src/lib/infect.c
+++ b/compel/src/lib/infect.c
@@ -313,6 +313,8 @@  err:
 
 int compel_resume_task(pid_t pid, int orig_st, int st)
 {
+	int ret = 0;
+
 	pr_debug("\tUnseizing %d into %d\n", pid, st);
 
 	if (st == COMPEL_TASK_DEAD) {
@@ -335,15 +337,17 @@  int compel_resume_task(pid_t pid, int orig_st, int st)
 		 */
 		if (orig_st == COMPEL_TASK_STOPPED)
 			kill(pid, SIGSTOP);
-	} else
+	} else {
 		pr_err("Unknown final state %d\n", st);
+		ret = -1;
+	}
 
 	if (ptrace(PTRACE_DETACH, pid, NULL, NULL)) {
 		pr_perror("Unable to detach from %d", pid);
 		return -1;
 	}
 
-	return 0;
+	return ret;
 }
 
 static int gen_parasite_saddr(struct sockaddr_un *saddr, int key)