mirror of
https://github.com/troglobit/libite.git
synced 2026-11-07 16:01:01 +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
@@ -17,6 +17,7 @@ progress
|
||||
rsync
|
||||
str
|
||||
strmatch
|
||||
systemf
|
||||
tempfile
|
||||
touch
|
||||
tree
|
||||
|
||||
@@ -17,6 +17,7 @@ TESTS += progress
|
||||
TESTS += rsync
|
||||
TESTS += str
|
||||
TESTS += strmatch
|
||||
TESTS += systemf
|
||||
TESTS += touch
|
||||
TESTS += tempfile
|
||||
TESTS += which
|
||||
|
||||
@@ -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