Janssens, Kitty wrote:
The problem is that pclose returns 0 in either case.
I've tried it with fork + execl too and there it's the same. The result
of execl is a negative number whether wireshark has started correctly or
not.
The result of execl() is a negative number only if the program didn't
start *at all*.
Furthermore, if the program *does* start, execl() doesn't return - the
process doing the execl() stops running the program that did the execl()
and starts running the program that execl() is starting.
Therefore, execl() *always* returns -1 if it returns at all. If it
succeeds, it doesn't return, as there's nothing to return to; it only
returns if it fails.
If you want the exit status of the program run by execl(), you have to
make a wait() or waitpid() call in the parent process to get the exit
status of the forked process that ran execl().