From: Gerd Knorr <kraxel@bytesex.org>
To: Michael Richardson <mcr@sandelman.ottawa.on.ca>
Cc: Werner Almesberger <wa@almesberger.net>,
BlaisorBlade <blaisorblade_spam@yahoo.it>,
user-mode-linux-devel@lists.sourceforge.net,
Lorenzo Colitti <lorenzo@colitti.com>,
Massimo Rimondini <rimondin@dia.uniroma3.it>
Subject: Re: [uml-devel] Re: [uml-user] Host processes never terminate on 2.6.9rc3 host (stuck in ptrace_stop)
Date: Thu, 21 Oct 2004 09:57:37 +0200 [thread overview]
Message-ID: <20041021075737.GA32566@bytesex> (raw)
In-Reply-To: <31004.1098316468@marajade.sandelman.ottawa.on.ca>
> I tend to believe that -9 should also override being traced as well.
> I can sort of understand that someone might think they can trace through
> a -9, but since that signal is never delivered to the process, nor can
> it be ignored, I can't understand why it matters.
> Sure, let the ptrace'r know that the process got a -9.
Ok, found a way around that. You can send a SIGKILL, then call
PTRACE_CONT, and now the process will see the SIGKILL and die.
The patch below fixes it for me for the skas case, not sure about
tt through.
Gerd
Index: linux-uml-2.6.9/arch/um/include/os.h
===================================================================
--- linux-uml-2.6.9.orig/arch/um/include/os.h 2004-10-20 10:56:02.000000000 +0200
+++ linux-uml-2.6.9/arch/um/include/os.h 2004-10-20 16:58:00.000000000 +0200
@@ -156,7 +156,7 @@ extern int os_lock_file(int fd, int excl
extern unsigned long os_process_pc(int pid);
extern int os_process_parent(int pid);
extern void os_stop_process(int pid);
-extern void os_kill_process(int pid, int reap_child);
+extern void os_kill_process(int pid, int reap_child, int trace_cont);
extern void os_usr1_process(int pid);
extern int os_getpid(void);
Index: linux-uml-2.6.9/arch/um/os-Linux/process.c
===================================================================
--- linux-uml-2.6.9.orig/arch/um/os-Linux/process.c 2004-10-20 10:55:52.000000000 +0200
+++ linux-uml-2.6.9/arch/um/os-Linux/process.c 2004-10-20 17:16:58.000000000 +0200
@@ -10,6 +10,7 @@
#include <linux/unistd.h>
#include <sys/mman.h>
#include <sys/wait.h>
+#include <sys/ptrace.h>
#include "os.h"
#include "user.h"
#include "user_util.h"
@@ -86,12 +87,13 @@ void os_stop_process(int pid)
kill(pid, SIGSTOP);
}
-void os_kill_process(int pid, int reap_child)
+void os_kill_process(int pid, int reap_child, int trace_cont)
{
kill(pid, SIGKILL);
- if(reap_child)
+ if (trace_cont)
+ ptrace(PTRACE_CONT, pid, NULL, NULL);
+ if (reap_child)
CATCH_EINTR(waitpid(pid, NULL, 0));
-
}
void os_usr1_process(int pid)
Index: linux-uml-2.6.9/arch/um/drivers/port_kern.c
===================================================================
--- linux-uml-2.6.9.orig/arch/um/drivers/port_kern.c 2004-10-20 10:55:44.000000000 +0200
+++ linux-uml-2.6.9/arch/um/drivers/port_kern.c 2004-10-20 14:36:10.000000000 +0200
@@ -112,7 +112,7 @@ static int port_accept(struct port_list
out_close:
os_close_file(fd);
if(pid != -1)
- os_kill_process(pid, 1);
+ os_kill_process(pid, 1, 0);
out:
return(ret);
}
@@ -262,9 +262,9 @@ void port_remove_dev(void *d)
struct port_dev *dev = d;
if(dev->helper_pid != -1)
- os_kill_process(dev->helper_pid, 0);
+ os_kill_process(dev->helper_pid, 0, 0);
if(dev->telnetd_pid != -1)
- os_kill_process(dev->telnetd_pid, 1);
+ os_kill_process(dev->telnetd_pid, 1, 0);
dev->helper_pid = -1;
dev->telnetd_pid = -1;
}
Index: linux-uml-2.6.9/arch/um/drivers/ubd_kern.c
===================================================================
--- linux-uml-2.6.9.orig/arch/um/drivers/ubd_kern.c 2004-10-20 10:56:28.000000000 +0200
+++ linux-uml-2.6.9/arch/um/drivers/ubd_kern.c 2004-10-20 14:36:49.000000000 +0200
@@ -470,7 +470,7 @@ static int io_pid = -1;
void kill_io_thread(void)
{
if(io_pid != -1)
- os_kill_process(io_pid, 1);
+ os_kill_process(io_pid, 1, 0);
}
__uml_exitcall(kill_io_thread);
Index: linux-uml-2.6.9/arch/um/drivers/line.c
===================================================================
--- linux-uml-2.6.9.orig/arch/um/drivers/line.c 2004-10-20 11:46:34.000000000 +0200
+++ linux-uml-2.6.9/arch/um/drivers/line.c 2004-10-20 14:34:38.000000000 +0200
@@ -638,7 +638,7 @@ static void winch_cleanup(void)
os_close_file(winch->fd);
}
if(winch->pid != -1)
- os_kill_process(winch->pid, 1);
+ os_kill_process(winch->pid, 1, 0);
}
}
__uml_exitcall(winch_cleanup);
Index: linux-uml-2.6.9/arch/um/kernel/skas/process.c
===================================================================
--- linux-uml-2.6.9.orig/arch/um/kernel/skas/process.c 2004-10-20 11:46:32.000000000 +0200
+++ linux-uml-2.6.9/arch/um/kernel/skas/process.c 2004-10-20 16:33:16.000000000 +0200
@@ -400,7 +400,7 @@ void switch_mm_skas(int mm_fd)
void kill_off_processes_skas(void)
{
#warning need to loop over userspace_pids in kill_off_processes_skas
- os_kill_process(userspace_pid[0], 1);
+ os_kill_process(userspace_pid[0], 1, 1);
}
void init_registers(int pid)
Index: linux-uml-2.6.9/arch/um/kernel/process.c
===================================================================
--- linux-uml-2.6.9.orig/arch/um/kernel/process.c 2004-10-20 10:56:58.000000000 +0200
+++ linux-uml-2.6.9/arch/um/kernel/process.c 2004-10-20 16:54:56.000000000 +0200
@@ -141,7 +141,7 @@ static int ptrace_child(void *arg)
if(ptrace(PTRACE_TRACEME, 0, 0, 0) < 0){
perror("ptrace");
- os_kill_process(pid, 0);
+ os_kill_process(pid, 0, 0);
}
os_stop_process(pid);
_exit(os_getpid() == pid);
Index: linux-uml-2.6.9/arch/um/kernel/helper.c
===================================================================
--- linux-uml-2.6.9.orig/arch/um/kernel/helper.c 2004-10-20 10:56:28.000000000 +0200
+++ linux-uml-2.6.9/arch/um/kernel/helper.c 2004-10-20 16:38:22.000000000 +0200
@@ -45,7 +45,7 @@ static int helper_child(void *arg)
errval = errno;
printk("execvp of '%s' failed - errno = %d\n", argv[0], errno);
os_write_file(data->fd, &errval, sizeof(errval));
- os_kill_process(os_getpid(), 0);
+ os_kill_process(os_getpid(), 0, 0);
return(0);
}
@@ -106,7 +106,7 @@ int run_helper(void (*pre_exec)(void *),
return(pid);
out_kill:
- os_kill_process(pid, 1);
+ os_kill_process(pid, 1, 0);
out_close:
os_close_file(fds[0]);
os_close_file(fds[1]);
Index: linux-uml-2.6.9/arch/um/kernel/tt/process_kern.c
===================================================================
--- linux-uml-2.6.9.orig/arch/um/kernel/tt/process_kern.c 2004-10-20 10:56:57.000000000 +0200
+++ linux-uml-2.6.9/arch/um/kernel/tt/process_kern.c 2004-10-20 16:31:31.000000000 +0200
@@ -66,7 +66,7 @@ void *switch_to_tt(void *prev, void *nex
reading = 1;
if((from->state == TASK_ZOMBIE) || (from->state == TASK_DEAD))
- os_kill_process(os_getpid(), 0);
+ os_kill_process(os_getpid(), 0, 0);
err = os_read_file(from->thread.mode.tt.switch_pipe[0], &c, sizeof(c));
if(err != sizeof(c))
@@ -82,7 +82,7 @@ void *switch_to_tt(void *prev, void *nex
prev_sched = current->thread.prev_sched;
if((prev_sched->state == TASK_ZOMBIE) ||
(prev_sched->state == TASK_DEAD))
- os_kill_process(prev_sched->thread.mode.tt.extern_pid, 1);
+ os_kill_process(prev_sched->thread.mode.tt.extern_pid, 1, 1);
/* This works around a nasty race with 'jail'. If we are switching
* between two threads of a threaded app and the incoming process
@@ -119,7 +119,7 @@ void release_thread_tt(struct task_struc
int pid = task->thread.mode.tt.extern_pid;
if(os_getpid() != pid)
- os_kill_process(pid, 0);
+ os_kill_process(pid, 0, 0);
}
void exit_thread_tt(void)
@@ -331,10 +331,10 @@ void kill_off_processes_tt(void)
me = os_getpid();
for_each_process(p){
if(p->thread.mode.tt.extern_pid != me)
- os_kill_process(p->thread.mode.tt.extern_pid, 0);
+ os_kill_process(p->thread.mode.tt.extern_pid, 0, 0);
}
if(init_task.thread.mode.tt.extern_pid != me)
- os_kill_process(init_task.thread.mode.tt.extern_pid, 0);
+ os_kill_process(init_task.thread.mode.tt.extern_pid, 0, 0);
}
void initial_thread_cb_tt(void (*proc)(void *), void *arg)
Index: linux-uml-2.6.9/arch/um/drivers/xterm.c
===================================================================
--- linux-uml-2.6.9.orig/arch/um/drivers/xterm.c 2004-10-20 11:46:34.000000000 +0200
+++ linux-uml-2.6.9/arch/um/drivers/xterm.c 2004-10-20 17:01:27.000000000 +0200
@@ -168,10 +168,10 @@ void xterm_close(int fd, void *d)
struct xterm_chan *data = d;
if(data->pid != -1)
- os_kill_process(data->pid, 1);
+ os_kill_process(data->pid, 1, 0);
data->pid = -1;
if(data->helper_pid != -1)
- os_kill_process(data->helper_pid, 0);
+ os_kill_process(data->helper_pid, 0, 0);
data->helper_pid = -1;
os_close_file(fd);
}
Index: linux-uml-2.6.9/arch/um/kernel/sigio_user.c
===================================================================
--- linux-uml-2.6.9.orig/arch/um/kernel/sigio_user.c 2004-10-20 10:57:05.000000000 +0200
+++ linux-uml-2.6.9/arch/um/kernel/sigio_user.c 2004-10-20 16:58:56.000000000 +0200
@@ -259,7 +259,7 @@ static void update_thread(void)
fail:
sigio_lock();
if(write_sigio_pid != -1)
- os_kill_process(write_sigio_pid, 1);
+ os_kill_process(write_sigio_pid, 1, 0);
write_sigio_pid = -1;
os_close_file(sigio_private[0]);
os_close_file(sigio_private[1]);
@@ -386,7 +386,7 @@ void write_sigio_workaround(void)
return;
out_kill:
- os_kill_process(write_sigio_pid, 1);
+ os_kill_process(write_sigio_pid, 1, 0);
write_sigio_pid = -1;
out_close2:
os_close_file(sigio_private[0]);
@@ -419,7 +419,7 @@ int read_sigio_fd(int fd)
static void sigio_cleanup(void)
{
if(write_sigio_pid != -1)
- os_kill_process(write_sigio_pid, 1);
+ os_kill_process(write_sigio_pid, 1, 0);
}
__uml_exitcall(sigio_cleanup);
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
next prev parent reply other threads:[~2004-10-21 8:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4173F1FD.6080004@colitti.com>
[not found] ` <87d5zgrkm2.fsf@bytesex.org>
2004-10-18 19:18 ` [uml-devel] Re: [uml-user] Host processes never terminate on 2.6.9rc3 host (stuck in ptrace_stop) BlaisorBlade
2004-10-18 21:26 ` Gerd Knorr
2004-10-18 22:23 ` BlaisorBlade
2004-10-19 5:00 ` Werner Almesberger
2004-10-19 15:47 ` BlaisorBlade
2004-10-19 16:15 ` Werner Almesberger
2004-10-19 17:58 ` Gerd Knorr
2004-10-20 23:54 ` Michael Richardson
2004-10-21 7:57 ` Gerd Knorr [this message]
2004-10-19 6:59 ` Henrik Nordstrom
2004-10-19 7:26 ` Gerd Knorr
2004-10-19 8:47 ` Henrik Nordstrom
2004-10-19 9:04 ` Gerd Knorr
2004-10-19 7:18 ` Gerd Knorr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20041021075737.GA32566@bytesex \
--to=kraxel@bytesex.org \
--cc=blaisorblade_spam@yahoo.it \
--cc=lorenzo@colitti.com \
--cc=mcr@sandelman.ottawa.on.ca \
--cc=rimondin@dia.uniroma3.it \
--cc=user-mode-linux-devel@lists.sourceforge.net \
--cc=wa@almesberger.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.