Web lists-archives.com

Re: [ANNOUNCEMENT] TEST: Cygwin 3.0.0-0.7




On 2/5/19 4:18 PM, Corinna Vinschen wrote:
> Hi folks,
> 
> 
> I uploaded a new Cygwin test release 3.0.0-0.7
> 

> Please test.
> 

There's another regression - regarding spawn, exec and waitpid,
loosing the exitstatus somewhere in between:

$ cat > dospawn.c <<EOF
#include <sys/types.h>
#include <sys/wait.h>
#include <process.h>
#include <stdio.h>

int main(int argc, char const **argv)
{
  if (argc > 1)
    {   
      int pid = spawnv(_P_NOWAITO, argv[1], &argv[1]);
      if (pid) 
        {
          int status = 0;
          pid_t wpid = waitpid(pid, &status, 0);
          if (wpid > 0)
            {
              printf("waitpid: pid %d status 0x%x\n", pid, status); 
              if (WIFEXITED(status))
                {
                  int ret = WEXITSTATUS(status);
                  return ret;
                }
            }
        }
    }   
  return 127;
}
EOF

$ gcc dospawn.c -o dospawn
$ ./dospawn /bin/bash -c /bin/false
waitpid: pid 123 status 0x0        <= 2.11.2 does provide status 0x100 as expected
$ echo $?
0        <= Actually I do expect the exit status of /bin/false to show up here.

It is important to have the exec() in between:
$ ./dospawn /bin/false
waitpid: pid 123 status 0x100
$ echo $?
1

Note that bash does detect it can simply exec("/bin/false"). With more complex
commands bash does not just exec():

$ ./dospawn /bin/bash -c ':; /bin/false'
waitpid: pid 123 status 0x100
$ echo $?
1

/haubi/

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple