In my code I need to execute /bin/bash
, but I wan't to do it without passing any arguments to it. I wrote this:
execl("/bin/bash", NULL);
Then, through some research, I realized that I also need to add type cast:
execl("bin/bash", (char*) NULL);
but GCC is still giving me warnings:
main.c:18:5: warning: null argument where non-null required (argument 2) [-Wnonnull]
if(execl("/bin/bash", (char*) NULL) == -1) {
^
main.c:18:5: warning: not enough variable arguments to fit a sentinel [-Wformat=]
What is the proper way of doing this, am I misunderstanding something, or am I using a completely wrong function call?