I'm trying to write a wrapper of execl
function, but the command doesn't run (with execl
directly it works)
Then I added a vfprintf
for debugging purpose. But vfprintf only prints /bin/ls
, so I think it's truncated somewhere in the middle.
What's wrong with my code?
int my_execl(const char *file, const char *format, ...)
{
int ret = 0;
va_list args;
va_start (args, format);
vfprintf (stdout, format, args);
ret = execl (file, format, args);
va_end (args);
return ret;
}
int main (int argc , char **argv)
{
my_execl ("/bin/ls", "/bin/ls", "-r", "-t", NULL);
return 0;
}