<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # process `process`對象是一個全局對象,可以在任何地方訪問到它。 它是[EventEmitter](#)的一個實例。 ### Exit Codes Node 執行程序正常情況下會返回 0,這也意味著,包括所有“異步”在內的操作都已結束。(筆者注:linux terminal 下使用 echo $? 查看,win cmd 下使用 echo %ERRORLEVEL% 查看)除此之外的其他返回狀態如下: - `1`**未捕獲的致命異常(Uncaught Fatal Exception)** - There was an uncaught exception, and it was not handled by a domain or an `uncaughtException` event handler. - `2` - 未使用(Unused) (reserved by Bash for builtin misuse) - `3`**解析錯誤(Internal JavaScript Parse Error)** - The JavaScript source code internal in Node's bootstrapping process caused a parse error. This is extremely rare, and generally can only happen during development of Node itself. - `4`**評估失敗(Internal JavaScript Evaluation Failure)** - The JavaScript source code internal in Node's bootstrapping process failed to return a function value when evaluated. This is extremely rare, and generally can only happen during development of Node itself. - `5`**致命錯誤(Fatal Error)** - There was a fatal unrecoverable error in V8. Typically a message will be printed to stderr with the prefix `FATAL ERROR`. - `6`**未正確的異常處理(Non-function Internal Exception Handler)** - There was an uncaught exception, but the internal fatal exception handler function was somehow set to a non-function, and could not be called. - `7`**異常處理函數運行時失敗(Internal Exception Handler Run-Time Failure)** - There was an uncaught exception, and the internal fatal exception handler function itself threw an error while attempting to handle it. This can happen, for example, if a `process.on('uncaughtException')` or `domain.on('error')` handler throws an error. - `8` - 未使用(Unused). In previous versions of Node, exit code 8 sometimes indicated an uncaught exception. - `9` - **無效的參數(Invalid Argument)** - Either an unknown option was specified, or an option requiring a value was provided without a value. - `10`**運行時失敗(Internal JavaScript Run-Time Failure)** - The JavaScript source code internal in Node's bootstrapping process threw an error when the bootstrapping function was called. This is extremely rare, and generally can only happen during development of Node itself. - `12`**無效的調試參數(Invalid Debug Argument)** - The `--debug` and/or `--debug-brk` options were set, but an invalid port number was chosen. - `>128`**信號退出(Signal Exits)** - If Node receives a fatal signal such as `SIGKILL` or `SIGHUP`, then its exit code will be `128` plus the value of the signal code. This is a standard Unix practice, since exit codes are defined to be 7-bit integers, and signal exits set the high-order bit, and then contain the value of the signal code. ### 事件: 'exit' 當進程將要退出時觸發。這是一個在固定時間檢查模塊狀態(如單元測試)的好時機。需要注意的是 'exit' 的回調結束后,主事件循環將不再運行,所以計時器也會失效。 監聽 `exit` 事件的例子: ~~~ process.on('exit', function() { // 設置一個延遲執行 setTimeout(function() { console.log('主事件循環已停止,所以不會執行'); }, 0); console.log('退出前執行'); }); ~~~ ### 事件: 'uncaughtException'(未捕獲錯誤) 當一個異常冒泡回歸到事件循環中就會觸發這個事件,如果建立了一個監聽器來監聽這個異常,默認的行為(打印堆棧跟蹤信息并退出)就不會發生。 監聽 `uncaughtException` 示例: ~~~ // 故意制造一個異常,而且不catch捕獲它. nonexistentFunc(); console.log('This will not run.'); ~~~ 注意,`uncaughtException`未捕獲異常是一個非常粗略的異常處理。 盡量不要使用它,使用 [domains](#) 來代替它,如果你已經使用了,請在不處理這個異常之后重啟你的應用。 請 *不要* 象使用node.js的`有錯誤回復執行`這樣使用.一個未處理異常意味著你的應用和你的擴展Node.js自身是有未知狀態的。盲目的恢復意味著*任何事情*都可能發生。 你在升級的系統時拉掉了電源線,然后恢復了。可能10次里有9次每一偶問題,但是第10次,你的系統就會崩潰。 你已經被警告。 ### Signal Events 當進程接收到信號時觸發。信號列表詳見 POSIX 標準的 sigaction(2)如 SIGINT、SIGUSR1 等。 監聽 `SIGINT` 信號的示例: ~~~ // 設置 'SIGINT' 信號觸發事件 process.on('SIGINT', function() { console.log('收到 SIGINT 信號。 退出請使用 Ctrl + D '); }); ~~~ 在大多數終端下,一個發送 `SIGINT` 信號的簡單方法是按下 `ctrl + c` 。 ### process.stdout 一個指向`標準輸出流(stdout)`的 `可寫的流(Writable Stream)`。 舉例: `console.log` 的實現 ~~~ console.log = function(d) { process.stdout.write(d + '\n'); }; ~~~ process.stderr 和 process.stdout 不像 Node 中其他的流(Streams) 那樣,他們通常是阻塞式的寫入。當其引用指向 `普通文件` 或者 `TTY文件描述符` 時他們就是阻塞的(注:TTY 可以理解為終端的一種,可聯想 Pu
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看