From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by sourceware.org (Postfix) with ESMTPS id 128EE385503A for ; Wed, 9 Jun 2021 13:12:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 128EE385503A Received: by mail-lj1-x233.google.com with SMTP id s22so11171903ljg.5 for ; Wed, 09 Jun 2021 06:12:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LBZCeZGAaWlDf7jxmPfHrwo4HmOZUTISFXEhBxHgPjY=; b=Xv1Cb6xK0cxpXMqtxwOpiqGHs053vrdqeDxyE/wdwT0TK4Ft8YtFxVAYXxmsick/LF g5DJEpTf+83X8oeoF6cbyQMNy9OcA40mmz/cwFBk8iGcl3hi7+upJthoA0TfY+Wrcep/ dNDxn8ZIoSNkRfO/TMjCe8TRm6SKlN0BAIkM77zHUYM+x6NvewdOExBmh4+xWz2CD8ZJ rck5IM1GiYftSTJGhrOnPCSw5yoh2cs0KBsGBjCPbka2VP5jHhuIVYesV4v6YjBdQA1J omltykDBD+MuQ4fvThoALD1xpU6gRWa+wa3QGrQBbbDcq28JA/ROhXrL25jV6BdHjrex jDcw== X-Gm-Message-State: AOAM530WVAWbqDqvYH6Hhi+1ZX2KeagszwyjDFOPQcY3W1kfuxhzcZAA HmgirNo5cue9QkzMxow46GVWuQBsx5kLu3hElHg= X-Google-Smtp-Source: ABdhPJx0gmB27icZgRSzixTkD0+Eg6afZz6F0j6OnOGNGoo5Y6oPbKvf1YxsEUjcd4mRI6yvRuLOM2tfLdbqYHCDVjM= X-Received: by 2002:a05:651c:201e:: with SMTP id s30mr14674611ljo.71.1623244377889; Wed, 09 Jun 2021 06:12:57 -0700 (PDT) MIME-Version: 1.0 References: <7298cb72-becb-80bb-b2df-d97bdb201e95@linaro.org> <11145e53-3fbc-0f04-33f8-b2d9981f0ea8@linaro.org> <4429f842-e9c7-b907-3374-6b48c6fc089e@linaro.org> In-Reply-To: <4429f842-e9c7-b907-3374-6b48c6fc089e@linaro.org> From: Godmar Back Date: Wed, 9 Jun 2021 09:12:46 -0400 Message-ID: Subject: Re: supporting terminal ownership assignment (tcsetpgrp()) in posix_spawn To: Adhemerval Zanella Cc: Libc-help X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jun 2021 13:13:01 -0000 On Wed, Jun 9, 2021 at 8:00 AM Adhemerval Zanella < adhemerval.zanella@linaro.org> wrote: > > The libc interface should be as generic possible to cover most users cases, > I really don't want to add a posix_spawnattr_tcsetpgrp_np that uses the > groupid implicit from POSIX_SPAWN_SETPGROUP to someone ask for a > posix_spawnattr_tcsetpgrp_np_ex so one can set the groupid. > > Also, requiring POSIX_SPAWN_SETPGROUP for posix_spawnattr_tcsetpgrp_np is > not really a good API, it adds subtle semantics (should it use a default > value set by posix_spawnattr_init or should we fail with EINVAL), and adds > complexity in the error path (we will need to either pre validate the > posix_spawnattr_t input before start the process creation or handle a > possible invalid combination on the helper process itself). > > That's why I am more inclined to follow the tcsetpgrp on the posix_spawn > extension and let the caller set the required groups. > > I just checked and I don't think this will even work. The caller cannot provide the process group id because the caller can't know it yet. A typical sequence in the first child of a pipeline is "setpgid(0, 0); tcsetpgrp(fd, getpgrp());" and AFAIK tcsetpgrp doesn't accept '0' to stand for the current process's process group.