mirror of
https://github.com/troglobit/libite.git
synced 2026-11-06 15:50:57 +00:00
Add support for systemf(), formatted system() replacement
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
7f3f4df9e9
commit
f1a1a21569
7 files changed
+116
-1
No files matched your search
@@ -0,0 +1,31 @@
|
||||
#include <err.h>
|
||||
#include "check.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
struct { char *cmd; int rc; } list[] = {
|
||||
{ "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)
|
||||
err(rc, "Failed command %s", list[i].cmd);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user