Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp630943rwb; Fri, 23 Sep 2022 01:50:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM48qAWUpsErrP5F90F6k2rvNyL+gIeWtJvXIcSRjKRbYN4lOGCmmlTS8UxEuEJB0Fi2GHzV X-Received: by 2002:a17:907:3f8b:b0:782:3668:3d26 with SMTP id hr11-20020a1709073f8b00b0078236683d26mr5913578ejc.85.1663923020694; Fri, 23 Sep 2022 01:50:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663923020; cv=none; d=google.com; s=arc-20160816; b=RhKpve4LnMWCywDB/P4mHDTOj5weu81jP7G0HmLIVQbhyKYYRH+JsGieUATOfjs389 Jfif7+VBhlvGhn/tBL0Rs2AArn2Ge78xy1nfWMVhNmPP78HPL7aJSgErQUB9xwD1nCoZ 1ILuUs+aGwFJ+nfBp7jrfyLKOXNGtUTQUj+OOlC/wGbRwb6xrErSqV8Qqx3y+l47kSOP cUtIgRKr30YvxS6xE1IJkvtaTDG0jkFDg4Ma+w+EfkL76pbtMxx3dkcqR6fdIarLOf38 NATawA9ESA4fAomvE1PejoRvDJgpqoqE4CavhyvbNsOeaq+u3Jh+z6L66SY3YKtq4j4e iJMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=z/GuP0I2zv0Asb5v6NyQlZkYA6e5Hu8WTgjcpJubWOY=; b=KJX8ECU0ZbU5XiThIGh2c62mSAlg+sdxMuP9E3jKgACsn/xBiMf9sWrGtfat0pm58v waMy8L0mPLbI6xBy8f0YL8NN0VUK7hgADkovZQaKBnGrZOd+VoY+gDFO2/WfsgyqmQ5Z lxlkDbqV7q7jfG4rDNRO7R3GhpyuQ1/SAylA6P5JH7bKqyv4bd5QUFYNRE9xBnjctwHY VGCkNptYCuDQwgS15XbgzQjmZxxkenH/Yg3GzNsvkbQwCJS4B40/dupx/YLWzcialLO8 gGcd3YxGu3ODxpr87ZbRJByruTbS9jUDltmCqu3i/vcI/mK7Sg3wCRk3j8iNE+/B7dDj n+EA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ds20-20020a170907725400b00781d6cda764si8617690ejc.912.2022.09.23.01.49.54; Fri, 23 Sep 2022 01:50:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230194AbiIWIki convert rfc822-to-8bit (ORCPT + 99 others); Fri, 23 Sep 2022 04:40:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230232AbiIWIk2 (ORCPT ); Fri, 23 Sep 2022 04:40:28 -0400 Received: from out30-54.freemail.mail.aliyun.com (out30-54.freemail.mail.aliyun.com [115.124.30.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86491CF486; Fri, 23 Sep 2022 01:40:19 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R831e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=cambda@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0VQW6EEv_1663922415; Received: from smtpclient.apple(mailfrom:cambda@linux.alibaba.com fp:SMTPD_---0VQW6EEv_1663922415) by smtp.aliyun-inc.com; Fri, 23 Sep 2022 16:40:16 +0800 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: Syscall kill() can send signal to thread ID From: Cambda Zhu In-Reply-To: <87illeedc5.fsf@oldenburg.str.redhat.com> Date: Fri, 23 Sep 2022 16:40:15 +0800 Cc: "Eric W. Biederman" , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Xuan Zhuo , Dust Li , Tony Lu Content-Transfer-Encoding: 8BIT Message-Id: <613994F7-054D-4992-A159-96D34B17BC7F@linux.alibaba.com> References: <69E17223-F0CA-4A4C-AAD7-065D6E6266D9@linux.alibaba.com> <87pmfn5tu1.fsf@email.froward.int.ebiederm.org> <87r102ejwo.fsf@oldenburg.str.redhat.com> <0CC7D0E7-71C5-4DAC-8A01-F9E13659F864@linux.alibaba.com> <87illeedc5.fsf@oldenburg.str.redhat.com> To: Florian Weimer X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Sep 23, 2022, at 15:53, Florian Weimer wrote: > >> I don't quite understand what you mean, sorry. But if kill() returns >> -ESRCH for tid which is not equal to tgid, kill() can only send signal >> to thread group via main thread id, that is what BSD did and manual >> said. It seems not odd? > > It's still odd because there's one TID per process that's valid for > kill by accident. That's all. > > Thanks, > Florian As far as I know, there is no rule forbidding 'process ID'(TGID on Linux) equals to main thread ID, is it right? If one wants to send signal to a specific thread, tgkill() can do that. As far as I understand, the difference between kill() and tgkill() is whether the signal is set on shared_pending, whatever the ID is a process ID or a thread ID. For Linux, the main thread ID just equals to the process ID. So the meaning of kill(main_tid, sig) is sending signal to a process, of which the PID equals to the first argument. It's not odd, I think. Thanks, Cambda