No, that's not what I meant. When you attach using GDB, there is no
way for GDB to determine if the process was previously stopped or
running.
> 2. stracing a stopped process. This caused the stopped process to
> continue. On further investigation, I found out that strace calls
> ptrace(PTRACE_SYSCALL), which restarts the child, but arranges for the
> child to be stopped at the next entry to or exit from a system call.
>
> IMHO, the new ptrace semantics adds a feature to strace. If someone
> tries to run strace a stopped process without the patch, it will just
> hang, whereas with the patch, it'll let the process continue. Even
> without the patch, if a process that sends itself a SIGCONT is straced,
> the process will not stop. I do not think this is an issue, considering
> that ppl will not get any info by running strace on a stopped process,
> until they send a SIGCONT.
>
> In conclusion, the action taken by the tracer depends on the mechanism
> it uses for monitoring the system calls. That said, it'll definitely be
> useful if the tracer could find out the state of the tracee at the time
> of attachment and take appropriate action. Given below, is a port of
> Vic's patch to 2.5.xx series -
> --------------------------------------------------------------------------------
> -- kernel/ptrace.c 2003-03-23 22:15:33.000000000 -0800
> +++ kernel/ptrace.c 2003-03-23 22:19:27.000000000 -0800
> @@ -115,7 +115,10 @@
> __ptrace_link(task, current);
> write_unlock_irq(&tasklist_lock);
>
> - force_sig_specific(SIGSTOP, task);
> + if (task->state != TASK_STOPPED)
> + force_sig_specific(SIGSTOP, task);
> + else
> + task->exit_code = SIGSTOP;
> return 0;
>
> bad:
I'll test this here, give me a day or two.
-- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/