mirror of
https://github.com/troglobit/libite.git
synced 2026-10-02 05:42:49 +07:00
Non-existing programs should return 127, and killing ourselves with -9 should return -1 For details, see system(3). Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
37 lines
621 B
C
37 lines
621 B
C
#include <err.h>
|
|
#include "check.h"
|
|
|
|
int main(void)
|
|
{
|
|
struct { char *cmd; int rc; } list[] = {
|
|
{ "/app/enoent", 127 },
|
|
{ "false", 1 },
|
|
{ "true", 0 },
|
|
{ "kill -9 $$", -1 },
|
|
{ "kill -QUIT $$", -1 },
|
|
{ "kill -INT $$", -1 }
|
|
};
|
|
|
|
for (size_t i = 0; i < NELEMS(list); i++) {
|
|
int rc;
|
|
|
|
rc = systemf("%s", list[i].cmd);
|
|
if (rc != list[i].rc) {
|
|
if (rc == -1)
|
|
err(rc, "Failed %s", list[i].cmd);
|
|
else
|
|
errx(rc, "Failed %s, rc %d vs %d", list[i].cmd, rc, list[i].rc);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* Local Variables:
|
|
* indent-tabs-mode: t
|
|
* c-file-style: "linux"
|
|
* End:
|
|
*/
|
|
|