From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by sourceware.org (Postfix) with ESMTPS id CA3A6385BF9E for ; Mon, 7 Jun 2021 23:57:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CA3A6385BF9E Received: by mail-lj1-x22a.google.com with SMTP id bn21so24553562ljb.1 for ; Mon, 07 Jun 2021 16:57:29 -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=w0Uwgz8szvBI1LtWHiXqS/8Lrdv0jlvXfGWNB40Trj8=; b=a+LkH5j4vVKf2OoBt95wP8/P+HsHQFqYUC6QbG2JQ2CwCui+CPyIye21jPjle4lYaD oGpbZlBElbjpGcnFw2UQ5GJqXl/oD6oqj6Y2zGT1d3WGenfdw8YKO9HeGgxwRLBZcc3l ScYMqpxhW3Xf/gMegIuDQx6ykzs8iFXWVddO+UZ4eHi99rWmT5LU1zbBm+rs+wO0J78x sdkew84itOh4hPsgpSdu2usgV4GQ9F1cpwNn2/859XlZLoCzmJ2n/XujXCTSS5vD5ZcL Q7iorGr93u1YD2uSeAraPvUaA5jS9ImQk2Y5HqVISysqphGxe+vtPfxEquvPanV+TGsv 9rlA== X-Gm-Message-State: AOAM530n3Bqqsqkev0qFgJ+W+Hc6KbOiTWA8dou7vWxvG7iuqQslMctv V3UDXsUSIgP5h80AQgbX2WnxtAgmuHRufcPmhMM= X-Google-Smtp-Source: ABdhPJyNWJvdJkLucfD2+fSQuBEBLJJLLjkHwgm4GYfnSYd82/EuDip3SV7DIh2Cx+EQGi2Nn4TP9czfzXWsFGXzwdw= X-Received: by 2002:a2e:bc25:: with SMTP id b37mr16351005ljf.129.1623110248708; Mon, 07 Jun 2021 16:57:28 -0700 (PDT) MIME-Version: 1.0 References: <7298cb72-becb-80bb-b2df-d97bdb201e95@linaro.org> In-Reply-To: From: Godmar Back Date: Mon, 7 Jun 2021 19:57:17 -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.8 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: Mon, 07 Jun 2021 23:57:40 -0000 On Mon, Jun 7, 2021 at 5:36 PM Adhemerval Zanella < adhemerval.zanella@linaro.org> wrote: > > Yeah I forgot the inherent race condition on this scheme. I think it > should be possible to add such interface as a posix_spawn file action: > > int posix_spawn_file_actions_tcsetpgrp_np (int fd) > > Not sure if it make sense to support a pid different than the created > helper process (which will eventually call execve) since it is something > the parent can do it itself. > > The Blackberry implementation [1] has a single flag, with no arguments. It doesn't pass a file descriptor. It appears undocumented, but I would guess that this means that the child's process group becomes the foreground process group of the controlling terminal, which in a kernel implementation may be directly accessible. In a library implementation, it would require obtaining a file descriptor, perhaps via `ctermid`, which would introduce another error situation that would need to be handled. I think either approach (flag or file action) would be fine; in the envisioned use case, it's likely that the caller already has an open file descriptor available that refers to the intended terminal. Incidentally, I also sent an email to the mailing list of the Austin group, though haven't received any replies. - Godmar [1] https://developer.blackberry.com/native/reference/core/com.qnx.doc.neutrino.lib_ref/topic/p/posix_spawnattr_setxflags.html