42-archive/42sh/42shelltest-tmp/support/sleep-and-write-on-stderr
2017-03-18 01:30:28 +01:00
..
description 42shelltester 2017-03-18 01:30:28 +01:00
main.c 42shelltester 2017-03-18 01:30:28 +01:00
Makefile 42shelltester 2017-03-18 01:30:28 +01:00
README.md 42shelltester 2017-03-18 01:30:28 +01:00

./sleep_and_write_on_stderr

A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL.

#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)
	{
		write(2, argv[2], strlen(argv[2]));
	}
	return (0);
}