I am trying to LD_PRELOAD the linux’s clone function. In my LD_PRELOADed version I need to log the input paramters before calling the original clone function. However, the problem is that clone takes variable number of arguments. It is declared like this.
int clone(int (*fn)(void *), void *child_stack, int flags, void *arg, ...
/* pid_t *pid, struct user_desc *tls, pid_t *ctid */ );
Now to pass these arguments to the original clone function, I must know the number of arguments that were passed in. How can I do that?
If there is a NULL terminator, you can call
va_argwhile it doesn’t returnNULL.