diff options
-rw-r--r-- | src/library_fs.js | 10 | ||||
-rw-r--r-- | system/include/libc/unistd.h | 6 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/library_fs.js b/src/library_fs.js index c30876f5..8d83048e 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -16,7 +16,7 @@ mergeInto(LibraryManager.library, { root: null, mounts: [], devices: [null], - streams: [null], + streams: [], nextInode: 1, nameTable: null, currentPath: '/', @@ -358,7 +358,7 @@ mergeInto(LibraryManager.library, { // MAX_OPEN_FDS: 4096, nextfd: function(fd_start, fd_end) { - fd_start = fd_start || 1; + fd_start = fd_start || 0; fd_end = fd_end || FS.MAX_OPEN_FDS; for (var fd = fd_start; fd <= fd_end; fd++) { if (!FS.streams[fd]) { @@ -1167,15 +1167,15 @@ mergeInto(LibraryManager.library, { // open default streams for the stdin, stdout and stderr devices var stdin = FS.open('/dev/stdin', 'r'); {{{ makeSetValue(makeGlobalUse('_stdin'), 0, 'stdin.fd', 'void*') }}}; - assert(stdin.fd === 1, 'invalid handle for stdin (' + stdin.fd + ')'); + assert(stdin.fd === 0, 'invalid handle for stdin (' + stdin.fd + ')'); var stdout = FS.open('/dev/stdout', 'w'); {{{ makeSetValue(makeGlobalUse('_stdout'), 0, 'stdout.fd', 'void*') }}}; - assert(stdout.fd === 2, 'invalid handle for stdout (' + stdout.fd + ')'); + assert(stdout.fd === 1, 'invalid handle for stdout (' + stdout.fd + ')'); var stderr = FS.open('/dev/stderr', 'w'); {{{ makeSetValue(makeGlobalUse('_stderr'), 0, 'stderr.fd', 'void*') }}}; - assert(stderr.fd === 3, 'invalid handle for stderr (' + stderr.fd + ')'); + assert(stderr.fd === 2, 'invalid handle for stderr (' + stderr.fd + ')'); }, ensureErrnoError: function() { if (FS.ErrnoError) return; diff --git a/system/include/libc/unistd.h b/system/include/libc/unistd.h index ef6ba3b3..995a84ea 100644 --- a/system/include/libc/unistd.h +++ b/system/include/libc/unistd.h @@ -7,9 +7,9 @@ extern "C" { #include <features.h> -#define STDIN_FILENO 1 -#define STDOUT_FILENO 2 -#define STDERR_FILENO 3 +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 #define SEEK_SET 0 #define SEEK_CUR 1 |