From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 6D2E5385AC28 for ; Thu, 27 Jan 2022 11:57:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6D2E5385AC28 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-505-SBWFIrbNOEGFjxXOFIN2fA-1; Thu, 27 Jan 2022 06:57:53 -0500 X-MC-Unique: SBWFIrbNOEGFjxXOFIN2fA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E03D884DA42; Thu, 27 Jan 2022 11:57:52 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.8]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2C7056F116; Thu, 27 Jan 2022 11:57:51 +0000 (UTC) From: Florian Weimer To: Adhemerval Zanella Cc: libc-alpha@sourceware.org Subject: Re: [glibc] posix: Add terminal control setting support for posix_spawn References: <20220125180124.B88AC3857C70@sourceware.org> <87bkzxpi6q.fsf@oldenburg.str.redhat.com> Date: Thu, 27 Jan 2022 12:57:49 +0100 In-Reply-To: (Adhemerval Zanella's message of "Thu, 27 Jan 2022 08:38:58 -0300") Message-ID: <87bkzxo0g2.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Jan 2022 11:57:56 -0000 * Adhemerval Zanella: > I did not considered the closefrom in conjunction with closefrom file > action and making a file action does make sense indeed. Maybe a better > approach would be to remove posix_spawnattr_tcsetpgrp_np and > posix_spawnattr_tcsetpgrp_np and add: > > int posix_spawn_file_actions_tcsetgrp_np (posix_spawn_file_actions_t *, > int fd); > > Similar to posix_spawn_file_actions_addfchdir_np. > > So to create a process and set the controlling terminal, one can use the > following sequence: > > int tcfd = open (_PATH_TTY, O_RDONLY, 0600); > > posix_spawnattr_t attr; > posix_spawnattr_init (&attr); > posix_spawnattr_setflags (&attr, POSIX_SPAWN_TCSETPGROUP); Why is POSIX_SPAWN_TCSETPGROUP needed? > posix_spawn_file_actions_t actions; > posix_spawn_file_actions_init (&actions); > posix_spawn_file_actions_tcsetgrp_np (&actions, tcfd); > > So users would be able to add a posix_spawn_file_actions_addclose or > posix_spawn_file_actions_addclosefrom_np. This would address my concern, yes. Thanks, Florian