* I'm trying to figure out whether there is a *legitimate*
* use of this flag which we should respect.
*/
- if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID
+ if ((flags & (CLONE_PARENT_SETTID|CLONE_PIDFD|CLONE_CHILD_SETTID
|CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0)
return RVAL_DECODED;
} else {
- if (flags & CLONE_PARENT_SETTID) {
+ if (flags & (CLONE_PARENT_SETTID|CLONE_PIDFD)) {
+ kernel_ulong_t addr = tcp->u_arg[ARG_PTID];
+
tprints(", parent_tid=");
- printnum_int(tcp, tcp->u_arg[ARG_PTID], "%u");
+ if (flags & CLONE_PARENT_SETTID)
+ printnum_int(tcp, addr, "%u");
+ else
+ printnum_fd(tcp, addr);
}
if (flags & CLONE_SETTLS) {
tprints(", tls=");
#include "tests.h"
#include <errno.h>
+#include <limits.h>
#include <sched.h>
#include <signal.h>
#include <stdio.h>
#include <sys/wait.h>
#include <unistd.h>
+#define XLAT_MACROS_ONLY
+#include "xlat/clone_flags.h"
+#undef XLAT_MACROS_ONLY
+
static const int child_exit_status = 42;
static pid_t pid;
SYSCALL_NAME, child_stack_printed, STACK_SIZE_ARG
"CLONE_PARENT_SETTID|SIGCHLD", *ptid, pid);
+ char buf[PATH_MAX];
+ if (readlink("/proc/self/fd/0", buf, sizeof(buf) - 1) > 0) {
+ *ptid = 0;
+ pid = do_clone(child, child_stack, child_stack_size,
+ CLONE_PIDFD|SIGCHLD, 0, ptid);
+ char *fname = 0;
+ if (asprintf(&fname, "/proc/self/fd/%d", *ptid) < 0)
+ perror_msg_and_fail("asprintf");
+ int rc = readlink(fname, buf, sizeof(buf) - 1);
+ if ((unsigned int) rc >= sizeof(buf))
+ perror_msg_and_fail("readlink");
+ buf[rc] = '\0';
+ printf("%s(child_stack=%#lx" STACK_SIZE_FMT ", flags=%s"
+ ", parent_tid=[%u<%s>]) = %d\n",
+ SYSCALL_NAME, child_stack_printed, STACK_SIZE_ARG
+ "CLONE_PIDFD|SIGCHLD", *ptid, buf, pid);
+ }
+
return 0;
}