[newlib-cygwin] Cygwin: kill(1): fix parsing of negative pid

Takashi Yano via Cygwin-cvs <[email protected]>
Newsgroups gmane.os.cygwin.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=3815e9939b2f5f9c5448c13225ca86154d948744

commit 3815e9939b2f5f9c5448c13225ca86154d948744
Author: Christian Franke <[email protected]>
Date:   Sat Apr 12 15:51:53 2025 +0200

    Cygwin: kill(1): fix parsing of negative pid
    
    Signed-off-by: Christian Franke <[email protected]>

Diff:
---
 winsup/utils/kill.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/winsup/utils/kill.cc b/winsup/utils/kill.cc
index bcabcd47c..1e6ab5c4b 100644
--- a/winsup/utils/kill.cc
+++ b/winsup/utils/kill.cc
@@ -372,7 +372,9 @@ main (int argc, char **argv)
 	case '?':
 	  if (gotasig) /* this is a negative pid, go ahead */
 	    {
-	      --optind;
+	      /* Reset optind because it points to the next argument if and
+		 only if the pid has one digit. */
+	      optind = av - argv;
 	      goto out;
 	    }
 	  optreset = 1;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.