DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 55SJXM9l2009340 Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 55SJXM9l2009340 Authentication-Results: delorie.com; dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=T35FTZK2 X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 090F63852127 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1751139201; bh=AP7iY0oUXmw69K5P3y4jasVCksrIpHB9rYrbosNCNT0=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=T35FTZK2G9ULGzRLVtD9JJlzFUlTq469hjljm+kRvLPoXiWwQ61+SUCYQULe/PHF3 CB5QLiCoZ1MNtHnFxxDzuJ3jKDWIVYI1hSgQw8JsH9/wEu/8I8VYlwYb+qZuYZmi1N Zfw4YlMI7b9yOK0NQdNW8Ej9zdxnHXZnHWAcYCTk= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A67C6385DDE6 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A67C6385DDE6 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1751139176; cv=none; b=mhQ3Fkh4FrhN4lDX3jf7IMlPxoE2VDjR8woMPkPKe0Td3+ZCwMgan2G1qF6tQHtukobWdDor0O4Bf6bfbqMDntcFRKkIoyb2uUGuki2hs4a8v0C5bniD3loJf1vTThaczP2sDRMdMA36Z08CCegEVAtCwfvi4cIhEMA0Mew8IJ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1751139176; c=relaxed/simple; bh=8pHTscNcDhoCGQg2H3Zt98j4lT0PMoYF3K0+GCcdiIA=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=mC47/hGzFWyCLzqqbbPuit3yVfVaZcUIlgH7MnGlVlUKc/+pFwV6zoSL1UV/htCkclZKTgTmx1YOwvU2VGvfcdCTpqlpzKtkNo2YZB8D/5gWFXFCuFhUAJ1YTj5c1zQJOPL9TlyAwROMz1aqLoVjvp8V24L/ons+5aDUstAuvtU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A67C6385DDE6 Date: Sat, 28 Jun 2025 12:32:55 -0700 (PDT) X-X-Sender: jeremyd AT resin DOT csoft DOT net To: cygwin AT cygwin DOT com Subject: setpgid non-compliance with POSIX? Message-ID: <3391453b-7914-a319-fad8-4729610558ea@jdrake.com> MIME-Version: 1.0 X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 List-Id: General Cygwin discussions and problem reports List-Archive: List-Post: List-Help: List-Subscribe: , From: Jeremy Drake via Cygwin Reply-To: Jeremy Drake Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Cygwin" I was looking at setpgid yesterday, and it seems deficient with respect to the errors required to be returned by the POSIX docs in https://pubs.opengroup.org/onlinepubs/9799919799/functions/setpgid.html Basically, it seems that setpgid allows any arbitrary positive integer to be set as pgid, rather than restricting to setting it to either the process's pid or to an existing pgid in the same session (sid). > The setpgid() function shall fail if: > > [EACCES] > The value of the pid argument matches the process ID of a child process > of the calling process and the child process has successfully executed > one of the exec functions. Not handled. In Cygwin context, I imagine the intent here is that you can only call setpgid on a forked child, not a spawned or execed one? I don't know how that might cause issues for things already using spawn* functions and expecting to setpgid (if there are any). It seems like the only POSIX-compliant way to spawn with a different pgid then is to use posix_spawn with POSIX_SPAWN_SETPGROUP. > [EINVAL] > The value of the pgid argument is less than 0, or is not a value > supported by the implementation. This seems to be handled correctly. > [EPERM] > The process indicated by the pid argument is a session leader. Not handled > [EPERM] > The value of the pid argument matches the process ID of a child process > of the calling process and the child process is not in the same session > as the calling process. Not handled > [EPERM] > The value of the pgid argument is valid but does not match the process > ID of the process indicated by the pid argument and there is no process > with a process group ID that matches the value of the pgid argument in > the same session as the calling process. Not handled > [ESRCH] > The value of the pid argument does not match the process ID of the > calling process or of a child process of the calling process. Partially handled - fails with ESRCH if no process with that ID exists, but fails with EPERM if the process does exist but is not the calling process or a child of the calling process. -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple