luvit / lit

Toolkit for developing, sharing, and running luvit/lua programs and libraries.
http://lit.luvit.io/
Apache License 2.0
245 stars 58 forks source link

Cleanup handles properly on exit; #241

Closed bjornbytes closed 6 years ago

bjornbytes commented 6 years ago

When running lit on macOS, I noticed a problem where output was being truncated:

$ luvi . -- --help
lit version: 3.6.0
luvi version: v2.7.6
command: --help

Lit CLI Commands
================
 lit help                    Show usage information.
 lit version                 Show just the lit version.
 lit update                  Update lit to the latest version.
 lit make appdir             Build appdir into a single executable.
 lit serve prefix            Start a lit package server (upstream or proxy).
                             `prefix` is the protocol and host.
                             EG: lit serve https://lit.luvit.io
Local configuration
-------------------
 lit auth username           Verify local private key and set username.
 lit up [url]                Go online.  Uses default upstream or url.
 lit down                    Go offline (disable upstream).
 lit config                  Print configuration.

Package Management
------------------
 lit init                    Bootstrap a new package.lua file or an init.lua
                             entry file
 lit ls [path]               List packages in folder or zip.
 lit install%$

I didn't notice this behavior with the main luvit binary, and after some investigation found that it had some logic to close handles on exit so they get properly flushed. Copying this over to lit fixed the output truncation.

squeek502 commented 6 years ago

+1

Relevant issues from when this was fixed in Luvit: https://github.com/luvit/lit/issues/222 and https://github.com/luvit/luvit/pull/1007

bjornbytes commented 6 years ago

Another thought I had about this: Since this handle-closing behavior ended up being necessary for 2 of the big luv(i)-based apps, it seems like it could be a "sensible default" type of thing. Maybe luvi could provide this out of the box, expose a helper function for it, or at least document it somewhere.