Skip to content

Instantly share code, notes, and snippets.

@morsoinferno
Created March 31, 2017 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morsoinferno/7029d11a03cabba31c6b152d51d7d5db to your computer and use it in GitHub Desktop.
Save morsoinferno/7029d11a03cabba31c6b152d51d7d5db to your computer and use it in GitHub Desktop.
05_dup1
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
void main()
{
int fd;
fd = dup2(1, 200);
close(STDOUT_FILENO);
//fd = dup(STDOUT_FILENO);
//duplico STDOUT en 200
//dup2(old_fd, new_fd)
//fd = dup2(1, 200);
//close(STDOUT_FILENO);
write(fd, "Mi mensaje\n", 12);
printf("fd = %d\n", fd); // se muestra por pantalla?
exit(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment