From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp50.i.mail.ru (smtp50.i.mail.ru [94.100.177.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id B76E3401A41 for ; Fri, 25 Oct 2019 02:04:55 +0300 (MSK) Date: Fri, 25 Oct 2019 02:04:46 +0300 From: Alexander Turenko Message-ID: <20191024230446.qzsmvikw5f4y3rvb@tkn_work_nb> References: <6d69f49ae7d4a58dfef92a654b0c6341df3f0344.1568152663.git.v.shpilevoy@tarantool.org> <20191024002155.6tn2b2zrju7wmi2n@tkn_work_nb> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Subject: Re: [Tarantool-patches] [tarantool-patches] Re: [PATCH 1/1] app: exit gracefully when a main script throws an error List-Id: Tarantool development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy Cc: tarantool-patches@freelists.org, tarantool-patches@dev.tarantool.org > >> @@ -678,6 +686,12 @@ tarantool_lua_run_script(char *path, bool interactive, > >> ev_run(loop(), 0); > >> /* The fiber running the startup script has ended. */ > >> script_fiber = NULL; > >> + /* > >> + * Result can't be obtained via fiber_join - script fiber > >> + * never dies if os.exit() was called. This is why diag > >> + * is checked explicitly. > >> + */ > >> + return diag_is_empty(diag_get()) ? 0 : -1; > > > > This is the only part I'm a bit tentative: can the diagnostic area be > > populated by a user somehow? I tried to do-- > > > > | fio.open('non_existent', {'O_RDONLY'}) > > | os.exit() > > > > --in the main script and it seems that it uses some other diagnostic > > area, because the fio error was not reported as the main script fail. > > Should it have been reported? No, current behaviour looks right for me. > Talking of why it is not now - well, yes, it uses another diagnostics > area. tarantool_lua_run_script() starts a special fiber to run a > script or a console. And the error is forwarded to the main fiber > only when the script fiber does it voluntary, in the end of > run_script_f(). > > In case of os.exit() the script fiber never finishes, and therefore > never moves its diag to the main fiber. Os.exit() breaks event loop > and freezes the current fiber. It makes ev_run() return in > tarantool_lua_run_script(). After that we see that the diag is empty, > because the script fiber never got to the point of filling it. Now I understood the logic, thanks!