Warning: Undefined array key "view" in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 2
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php:2) in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 47
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php:2) in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 48
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php:2) in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 49
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php:2) in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 50
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php:2) in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 51
/* Effettua la manipolazione dei canali standard output ed error */
#include
#include
#include
#include
#define STDIN 0
#define STDOUT 1
#define STDERR 2
#define LOGNAME "file.log"
int main() {
int fd;
printf("messaggio n.1 sullo standard output\n");
perror("errore n.1 simulato"); // dprintf(STDERR, "errore n.1 simulato\n");
if ((fd = open(LOGNAME, O_WRONLY | O_CREAT | O_TRUNC, 0600)) == -1) {
perror(LOGNAME);
exit(1);
}
close(STDOUT);
dup(fd);
printf("messaggio n.2 sullo standard output\n");
perror("errore n.2 simulato");
close(STDERR);
dup(fd);
printf("messaggio n.3 sullo standard output\n");
perror("errore n.3 simulato");
}