vendredi 1 juin 2018

How to capture the return value of timeout in linux

Could any one please tell me how to capture the o/p of timeout utility. As i have captured like below but it is not getting as expected.

std::string syscommand = "timeout -s KILL 1s command";
     int res = system(syscommand.c_str());
     std::cout << res;


As i gone through some post and i found o/p should be like below.

    124 if command times out
    125 if timeout itself fails
    126 if command is found but cannot be invoked
    127 if command cannot be found
    137 if command is sent the KILL(9) signal (128+9)
    the exit status of command otherwise

    and how to print the error no too.

Aucun commentaire:

Enregistrer un commentaire