42-archive/42sh/42ShellTester/support/sleep-and-exit-with-status
2017-03-24 17:43:33 +01:00
..
description with 42shelltester error 2017-03-24 17:43:33 +01:00
main.c with 42shelltester error 2017-03-24 17:43:33 +01:00
Makefile with 42shelltester error 2017-03-24 17:43:33 +01:00
README.md with 42shelltester error 2017-03-24 17:43:33 +01:00

./sleep_and_exit_with_status

A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument.

#include <unistd.h>
#include <string.h>
#include <stdlib.h>

int	main(int argc, char **argv)
{
	int seconds;

	seconds = 1;
	if (argc > 1)
		seconds = atoi(argv[1]);
	sleep(seconds);
	if (argc > 2)
		return (atoi(argv[2]));
	return (0);
}