All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Pedro Alves <palves-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Mike Frysinger <vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>,
	"Michael Kerrisk (man-pages)"
	<mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	pacman-ptgZXYu0fikgsBAKwltoeQ@public.gmane.org,
	linux-man <linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	lkml <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Denys Vlasenko <dvlasenk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Jan Kratochvil
	<jan.kratochvil-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: Re: ptrace.2: PTRACE_KILL needs a stopped process too
Date: Wed, 9 May 2012 22:12:19 +0200	[thread overview]
Message-ID: <20120509201219.GA32051@redhat.com> (raw)
In-Reply-To: <4FAAC706.6000808-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

On 05/09, Pedro Alves wrote:
>
> On 05/09/2012 04:09 PM, Mike Frysinger wrote:
>
> > probably not that big of a deal, but the reason i like using
> > ptrace(PTRACE_KILL) over a raw kill() is that you are less likely to kill the
> > wrong process by accident.  maybe not that big of a deal in practice though.
>
>
> And you can do tgkill instead.  It was specifically invented to handle the
> reuse case.

tgkill() can kill the wrong process/thread too, although it lessens the risk.

But I don't really understand the problem. The traced thread can't go away
until the tracer does wait/detach, and thus its pid can't be reused?

May be, "by accident" above means something else, not pid reuse...

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Oleg Nesterov <oleg@redhat.com>
To: Pedro Alves <palves@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>,
	"Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>,
	pacman@kosh.dhis.org, linux-man <linux-man@vger.kernel.org>,
	lkml <linux-kernel@vger.kernel.org>,
	Denys Vlasenko <dvlasenk@redhat.com>, Tejun Heo <tj@kernel.org>,
	Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: Re: ptrace.2: PTRACE_KILL needs a stopped process too
Date: Wed, 9 May 2012 22:12:19 +0200	[thread overview]
Message-ID: <20120509201219.GA32051@redhat.com> (raw)
In-Reply-To: <4FAAC706.6000808@redhat.com>

On 05/09, Pedro Alves wrote:
>
> On 05/09/2012 04:09 PM, Mike Frysinger wrote:
>
> > probably not that big of a deal, but the reason i like using
> > ptrace(PTRACE_KILL) over a raw kill() is that you are less likely to kill the
> > wrong process by accident.  maybe not that big of a deal in practice though.
>
>
> And you can do tgkill instead.  It was specifically invented to handle the
> reuse case.

tgkill() can kill the wrong process/thread too, although it lessens the risk.

But I don't really understand the problem. The traced thread can't go away
until the tracer does wait/detach, and thus its pid can't be reused?

May be, "by accident" above means something else, not pid reuse...

Oleg.


  parent reply	other threads:[~2012-05-09 20:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20091216004533.22261.qmail@kosh.dhis.org>
     [not found] ` <20091216004533.22261.qmail-ptgZXYu0fikgsBAKwltoeQ@public.gmane.org>
2012-04-22 18:56   ` ptrace.2: PTRACE_KILL needs a stopped process too Michael Kerrisk (man-pages)
2012-04-22 18:56     ` Michael Kerrisk (man-pages)
     [not found]     ` <CAKgNAkhtu8d0NKcTwWyCA8qWgz8Lag+GcpEE1=YMVe_Nh8XJ9Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-04-22 20:04       ` Oleg Nesterov
2012-04-22 20:04         ` Oleg Nesterov
     [not found]         ` <20120422200459.GA7519-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-05-02 12:06           ` Pedro Alves
2012-05-02 12:06             ` Pedro Alves
2012-05-09 15:09           ` Mike Frysinger
2012-05-09 15:09             ` Mike Frysinger
     [not found]             ` <201205091109.35637.vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
2012-05-09 19:35               ` Pedro Alves
2012-05-09 19:35                 ` Pedro Alves
     [not found]                 ` <4FAAC706.6000808-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-05-09 20:12                   ` Oleg Nesterov [this message]
2012-05-09 20:12                     ` Oleg Nesterov
     [not found]                     ` <20120509201219.GA32051-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-05-09 16:41                       ` Mike Frysinger
2012-05-09 16:41                         ` Mike Frysinger
2012-05-09 21:14                         ` Oleg Nesterov
     [not found]                           ` <20120509211429.GA2455-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-05-09 22:16                             ` Pedro Alves
2012-05-09 22:16                               ` Pedro Alves
2012-05-09 22:08                     ` Pedro Alves

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=20120509201219.GA32051@redhat.com \
    --to=oleg-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=dvlasenk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=jan.kratochvil-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=pacman-ptgZXYu0fikgsBAKwltoeQ@public.gmane.org \
    --cc=palves-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org \
    /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.