--- /dev/null
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+int main() {
+ int out_file_fd = open("ouput.txt", O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
+ if (out_file_fd < 0) {
+ perror("open failure\n");
+ exit(EXIT_FAILURE);
+ }
+
+ dup2(out_file_fd, STDOUT_FILENO);
+
+ execl("/bin/ls", "ls", (char*)NULL);
+
+ close(out_file_fd);
+
+ return EXIT_SUCCESS;
+}