22 CHECK ((handle =
open (
"child-rox")) > 1,
"open \"child-rox\"");
26 "try to write \"child-rox\"");
38 fail (
"bad command-line arguments");
39 if (
atoi (argv[1]) > 1)
44 snprintf (cmd,
sizeof cmd,
"child-rox %d",
atoi (argv[1]) - 1);
45 CHECK ((child =
exec (cmd)) != -1,
"exec \"%s\"", cmd);
47 CHECK (
wait (child) == 12,
"wait for \"child-rox\"");
int main(int argc UNUSED, char *argv[])
static void try_write(void)
const char * test_name
Child process run by rox-child and rox-multichild tests.
static int isdigit(int c)
#define UNUSED
GCC lets us add "attributes" to functions, function parameters, etc.
static void wait(struct intq *q, struct thread **waiter)
int snprintf(char *buffer, size_t buf_size, const char *format,...)
Like printf(), except that output is stored into BUFFER, which must have space for BUF_SIZE character...
int atoi(const char *s)
Converts a string representation of a signed decimal integer in S into an ‘int’, which is returned.
int open(const char *file)
int write(int fd, const void *buffer, unsigned size)
pid_t exec(const char *file)
void fail(const char *format,...)
void msg(const char *format,...)
#define CHECK(SUCCESS,...)
Takes an expression to test for SUCCESS and a message, which may include printf-style arguments.