Changes in uspace/app/getterm/getterm.c [9c4cf0d:1c635d6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/getterm/getterm.c
r9c4cf0d r1c635d6 36 36 37 37 #include <sys/types.h> 38 #include <fcntl.h> 38 39 #include <unistd.h> 39 40 #include <stdio.h> … … 42 43 #include <errno.h> 43 44 #include <loc.h> 44 #include <vfs/vfs.h>45 45 #include "version.h" 46 46 #include "welcome.h" … … 58 58 } 59 59 60 static void reopen(FILE **stream, int fd, const char *path, int mode,61 const char * fmode)60 static void reopen(FILE **stream, int fd, const char *path, int flags, 61 const char *mode) 62 62 { 63 63 if (fclose(*stream)) … … 66 66 *stream = NULL; 67 67 68 int oldfd = vfs_lookup_open(path, WALK_REGULAR, mode);68 int oldfd = open(path, flags); 69 69 if (oldfd < 0) 70 70 return; 71 71 72 72 if (oldfd != fd) { 73 if ( vfs_clone(oldfd, fd, false) != fd)73 if (dup2(oldfd, fd) != fd) 74 74 return; 75 75 76 if ( vfs_put(oldfd))76 if (close(oldfd)) 77 77 return; 78 78 } 79 79 80 *stream = fdopen(fd, fmode);80 *stream = fdopen(fd, mode); 81 81 } 82 82 … … 141 141 snprintf(term_node, LOC_NAME_MAXLEN, "%s/%s", locfs, term); 142 142 143 reopen(&stdin, 0, term_node, MODE_READ, "r");144 reopen(&stdout, 1, term_node, MODE_WRITE, "w");145 reopen(&stderr, 2, term_node, MODE_WRITE, "w");143 reopen(&stdin, 0, term_node, O_RDONLY, "r"); 144 reopen(&stdout, 1, term_node, O_WRONLY, "w"); 145 reopen(&stderr, 2, term_node, O_WRONLY, "w"); 146 146 147 147 if (stdin == NULL)
Note:
See TracChangeset
for help on using the changeset viewer.