// build with: gcc -o conftest_rl.exe -g -O2  -Zhigh-mem -Zomf -Zargs-wild -Zargs-resp -lcx conftest_rl.c -lcx -lreadline 
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <readline/readline.h>
#include <readline/history.h>

int main(int argc, char **argv)
{
	int fd;
	char *line;

	close(0);
	close(1);
	fd = open("/dev/null", 2);	/* should get fd 0 */
	dup(fd);
	line = readline("giveittome> ");

	/* some printfs don't handle NULL for %s */
	printf("got <%s>\n", line ? line : "(NULL)");
	return 0;
}
