Status = 2943 from waitpid?

Status = 2943 from waitpid?

Post by Jeffrey Walto » Fri, 10 Jun 2011 13:51:35



Hi All,

I'm ptrace'ing a process. After fork/exec and then a wait on the
child, I'm getting a status of 2943. I'm testing for failure, but
waitpid reports non-failure. I've looked in <sys/wait.h>, but the 2943
is not defined and does not appear to be a bit mask.

Any ideas on where I should look?

Jeff

int DoParentProcess(int childPid)
{
  int err, ret, status;

  for( ; ; )
  {
    ret = waitpid(childPid, &status, 0);
    err = errno;

    ///////////////////////////////////////

    if(ret == -1)
    {
      cerr << "Failed to wait on child process, errno = " << err <<
endl;
      return err;
    }

    ///////////////////////////////////////

    cout << "Parent: wait status = " << status << endl;

    if(WIFEXITED(status))
      break;

    ///////////////////////////////////////

    ret = ptrace(PTRACE_CONT, childPid, 0, 0);
    err = errno;

    if(ret == -1)
    {
      cerr << "Failed to continue child process, errno = " << err <<
endl;
      return err;
    }
  }

  return 0;

Quote:}

 
 
 

Status = 2943 from waitpid?

Post by Thomas Muelle » Fri, 10 Jun 2011 16:35:54



> I'm ptrace'ing a process. After fork/exec and then a wait on the child,
> I'm getting a status of 2943. I'm testing for failure, but waitpid
> reports non-failure. I've looked in <sys/wait.h>, but the 2943 is not
> defined and does not appear to be a bit mask.

> Any ideas on where I should look?

man 2 waitpid, specifically the Wxxx() macros.
In your case (2943, 0xB7F), the child is in the stopped state and
the cause was signal 11 (SIGSEGV).

HTH,

--
Thomas Mueller

 
 
 

Status = 2943 from waitpid?

Post by Philip Paep » Sat, 11 Jun 2011 07:54:14



> I'm ptrace'ing a process. After fork/exec and then a wait on the
> child, I'm getting a status of 2943. I'm testing for failure, but
> waitpid reports non-failure. I've looked in <sys/wait.h>, but the 2943
> is not defined and does not appear to be a bit mask.


followups you got there are equally valid on FreeBSD as on Linux and indeed
any other operating system that implements the POSIX specification.

There is no need to try to interpret the return values from waitpid() and
friends directly.  You should instead use the W*() macros described in the
wait(2) manual page.

 - Philip

--
Philip Paeps                                    Please don't email any replies

 
 
 

1. Problem with status value returned by waitpid

Hello guys,

I'm having a problem with the value of myStat returned by waitpid(
pid, &myStat, 0). The child exits with a not null value but i get
myStat = 0.

Here is the C code (tests for errors removed):

-------------------------------------------------
pipe( pfd );
pid = fork();
if( pid == 0 ) {
  dup2( pfd[1], STDOUT_FILENO );
  dup2( pfd[1], STDERR_FILENO );
  close( pfd[0] );
  close( pfd[1] );
  exitcode = system( command );
  exitcode = exitcode >> 8;
  exit( exitcode );
else {
  close( pfd[1] );
  read( pfd[0], ... ); /* reading data returned by exec of command */

close( pfd[0] );
signal( SIGCHLD, SIG_DFL );
waitpid( pid, &status, 0 );
-------------------------------------------------

command is a Bourne shell script :
#!/bin/sh
exit 5

When logging exitcode value in the child, i do get 5 but status in the
parent is 0.

But if I use the following piece of code, it works fine :

-------------------------------------------------
pipe( pfd );
pid = fork();
if( pid == 0 ) {
  for( fd = 0; fd < 31; fd++ )
    if( fd != pfd[1] ) close( fd );

  dup( pfd[1] );
  dup( pfd[1] );
  dup( pfd[1] );
  close( pfd[1] );

  exitcode = system( command );
  exitcode = exitcode >> 8;
  exit( exitcode );
else {
  read( pfd[0], ... ); /* reading data returned by exec of command */

close( pfd[0] );
close( pfd[1] );
signal( SIGCHLD, SIG_DFL );
waitpid( pid, &status, 0 );
-------------------------------------------------

I guess it has to do with the use of dup2 but i can't figure out why.
If anyone has any idea of what's wrong with my code .....

Thanks.

Christian

2. pb with #error in <values.h>

3. AMD status map status update solved!

4. Dividing the physical memory

5. Couldn't open status file /var/lock/samba/STATUS....LCK

6. apache & php4

7. Move "used FPU status" into new non-atomic thread_info->status field.

8. Problem with kde and mymetype

9. eth0 : transmit timed out, status 0000, PHY status 782d, resetting

10. Exit status, $?, and term status

11. Move "used FPU status" into new non-atomic thread_info->status field.

12. eth0:transmit timed out, tx-status 00 status e000

13. eth0 transmit timed out status 0000 phy status 782d