getpgid 未使用 valgrind 实现
getpgid not implemented with valgrind
考虑这个例子:
#include <stdio.h>
#include <unistd.h>
int main()
{
int pgid;
if ((pgid = getpgid(0)) == -1)
perror("getpgid");
else
printf("pgid : %d\n", pgid);
}
当我 运行 这个程序没有 valgrind 时,一切正常,并且打印了 pgid。
每当我使用 valgrind 时,perror
都会打印 getpgid: Function not implemented
.
getpgid
在 valgrind 下不可用正常吗?
是否有任何替代方法来获取特定 pid 的 pgid(不包括
getpgrp
) ?
我正在使用 macOS Sierra 10.12.6 和 valgrind-3.15.0。
看来 valgrind 在执行某些系统调用时可能会遇到一些麻烦。
在 valgrind 跟踪中,我有:
--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.
所以我需要为该函数创建一个包装器,它应该可以工作。
我会将错误报告给支持人员。
您不应该通过 valgrind on Mac OS X 进行测试,因为在 Sierra 之后,它不受支持。相反,这也是我所做的,通过虚拟机软件安装 ubuntu 然后 运行 valgrind。
macOS Mojave 10.14.6 的 unistd.h
有以下部分,
#if __DARWIN_UNIX03
void encrypt(char *, int) __DARWIN_ALIAS(encrypt);
#else /* !__DARWIN_UNIX03 */
int encrypt(char *, int);
#endif /* __DARWIN_UNIX03 */
int fchdir(int);
long gethostid(void);
pid_t getpgid(pid_t);
pid_t getsid(pid_t);
经验法则,始终尽量便携!
顺便说一下,正如@Andrew Henle 提到的,pid_t
可以是系统相关类型。但是,它不应该是 unsigned type 以保持可移植性,因为在失败的情况下它可以作为 -1
返回。此外,在 Mac OS X 上它的类型是 int
,如下所示
typedef int __int32_t;
typedef __int32_t __darwin_pid_t; /* [???] process and group IDs */
typedef __darwin_pid_t pid_t;
考虑这个例子:
#include <stdio.h>
#include <unistd.h>
int main()
{
int pgid;
if ((pgid = getpgid(0)) == -1)
perror("getpgid");
else
printf("pgid : %d\n", pgid);
}
当我 运行 这个程序没有 valgrind 时,一切正常,并且打印了 pgid。
每当我使用 valgrind 时,perror
都会打印 getpgid: Function not implemented
.
getpgid
在 valgrind 下不可用正常吗?是否有任何替代方法来获取特定 pid 的 pgid(不包括
getpgrp
) ?
我正在使用 macOS Sierra 10.12.6 和 valgrind-3.15.0。
看来 valgrind 在执行某些系统调用时可能会遇到一些麻烦。
在 valgrind 跟踪中,我有:
--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.
所以我需要为该函数创建一个包装器,它应该可以工作。 我会将错误报告给支持人员。
您不应该通过 valgrind on Mac OS X 进行测试,因为在 Sierra 之后,它不受支持。相反,这也是我所做的,通过虚拟机软件安装 ubuntu 然后 运行 valgrind。
macOS Mojave 10.14.6 的 unistd.h
有以下部分,
#if __DARWIN_UNIX03
void encrypt(char *, int) __DARWIN_ALIAS(encrypt);
#else /* !__DARWIN_UNIX03 */
int encrypt(char *, int);
#endif /* __DARWIN_UNIX03 */
int fchdir(int);
long gethostid(void);
pid_t getpgid(pid_t);
pid_t getsid(pid_t);
经验法则,始终尽量便携!
顺便说一下,正如@Andrew Henle 提到的,pid_t
可以是系统相关类型。但是,它不应该是 unsigned type 以保持可移植性,因为在失败的情况下它可以作为 -1
返回。此外,在 Mac OS X 上它的类型是 int
,如下所示
typedef int __int32_t;
typedef __int32_t __darwin_pid_t; /* [???] process and group IDs */
typedef __darwin_pid_t pid_t;