From owner-freebsd-hackers Wed May 30 5:45:22 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from public.guangzhou.gd.cn (mail2-smtp.guangzhou.gd.cn [202.105.65.222]) by hub.freebsd.org (Postfix) with SMTP id 8944737B422 for ; Wed, 30 May 2001 05:45:17 -0700 (PDT) (envelope-from gzjyliu@public.guangzhou.gd.cn) Received: from fatcow.home([203.93.59.244]) by public.guangzhou.gd.cn(JetMail 2.5.3.0) with SMTP id jmb3b153eb2; Wed, 30 May 2001 12:43:29 -0000 Received: (from jyliu@localhost) by fatcow.home (8.11.3/8.11.3) id f4UCjCe00677; Wed, 30 May 2001 20:45:12 +0800 (CST) (envelope-from gzjyliu@public.guangzhou.gd.cn) X-Authentication-Warning: fatcow.home: jyliu set sender to gzjyliu@public.guangzhou.gd.cn using -f To: freebsd-hackers@FreeBSD.org Subject: Weird PT_DETACH From: Jiangyi Liu Date: 30 May 2001 20:45:12 +0800 Message-ID: <878zjf0zvr.fsf@fatcow.home> Lines: 45 User-Agent: Gnus/5.090001 (Oort Gnus v0.01) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hi all, The ptrace(2) man page is probably outdated. I used PT_DETACH in the following code, but it didn't run ./test. I also tried to use ptrace(PT_DETACH, pid, (caddr_t)1, 0) to detach, but it failed too. BTW, if I omit wait(0) and ptrace(PT_DETACH, ...) in the code, after it runs there is a process sticking to the system. Even kill -9 can't kill it. $ ps aux | grep jyliu ... jyliu 423 0.0 0.1 216 100 p2 TX 7:41AM 0:00.00 (test) ... $ kill -9 423 $ ps aux | grep jyliu ... jyliu 423 0.0 0.1 216 100 p2 TX 7:41AM 0:00.00 (test) ... So it's still there. Quite funny. Any clue? Jiangyi ---code begins here #include #include #include int main() { pid_t pid; if(!(pid=fork())) { /* child */ ptrace(PT_TRACE_ME, 0, 0, 0); puts("child speaking"); execve("./test", NULL, NULL); } else { wait(0); ptrace(PT_DETACH, pid, 0, 0); exit(0); } } ---code ends here To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message