commit 18709578a20d2ee4a9bea7cc89710d230b9402ce
parent b1304f7ab2facdaec4d97b480535c1633d03247c
Author: tc@box <none@none>
Date: Fri, 21 May 2010 15:08:49 +0000
hang child proc before it starts
Diffstat:
1 file changed, 17 insertions(+), 0 deletions(-)
diff --git a/src/9vx/ratrace/ratrace.c b/src/9vx/ratrace/ratrace.c
@@ -29,6 +29,22 @@ cwrite(int fd, char *path, char *cmd, int len)
threadexits(nil);
}
}
+
+void
+hang(int pid)
+{
+ char *ctl;
+ int cfd;
+ ctl = smprint("/proc/%d/ctl", pid);
+ if ((cfd = open(ctl, OWRITE)) < 0)
+ die(smprint("%s: %r", ctl));
+ if (write(cfd, "hang", 4) < 4) {
+ print("%s: %r\n", ctl);
+ exits("can't hang child");
+ }
+
+}
+
void
reader(void *v)
{
@@ -154,6 +170,7 @@ threadmain(int argc, char **argv)
exits("fork failed");
}
if(pid == 0) {
+ hang(getpid());
exec(cmd, args);
fprint(2, "Bad exec: %s: %r\n", cmd);
exits("Bad exec");