Search code examples
cmacosunixvalgrind

getpgid not implemented with valgrind


Considering this example :

#include <stdio.h>
#include <unistd.h>

int     main()
{
    int pgid;

    if ((pgid = getpgid(0)) == -1)
        perror("getpgid");
    else
        printf("pgid : %d\n", pgid);
}

When I'm running this program without valgrind, everything is going right, and the pgid is printed. Whenever I'm using valgrind, perror will print getpgid: Function not implemented.

  • Is it normal that getpgid is not available under valgrind ?

  • Is there any alternative to get the pgid of a specific pid (excluding getpgrp) ?

I'm using macOS Sierra 10.12.6 and valgrind-3.15.0.


Solution

  • It seem that valgrind could have some trouble to perform some syscall.

    In the valgrind trace, I'm having :

    --17135-- WARNING: unhandled amd64-darwin syscall: unix:151
    --17135-- You may be able to write your own handler.
    --17135-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
    --17135-- Nevertheless we consider this a bug.  Please report
    --17135-- it at http://valgrind.org/support/bug_reports.html.
    

    So I need to create a wrapper for the function, and it should work. I will report the bug to the support.