Clozure / ccl

Clozure Common Lisp
http://ccl.clozure.com
Apache License 2.0
857 stars 103 forks source link

CCL does not exit after evaluation with --batch option #470

Open galdor opened 11 months ago

galdor commented 11 months ago

According to the documentation, --batch makes CCL exit on stdin EOF.

Running:

ccl --no-init --batch --quiet --eval '(format t "Hello world!~%")'

Leads to CCL printing the message correctly and hanging there without exiting until one hits ^D to explicitely send EOF. In this state, using ^C to send SIGINT causes CCL to enter the debugger (really not something expected with --batch_).

Stracing CCL shows that it is reading the standard input:

[pid 21446] write(1, "Hello world!\n", 13Hello world!
) = 13
[pid 21446] read(0,  <unfinished ...>

I would expect CCL to exit after all forms passed to --eval options have been evaluated.

Environment: CCL 1.12.2 running on Linux x86_64.

phoe commented 11 months ago

If it's meaningful in any way, sbcl --script doesn't quit without a manual ^D either, and requires an explicit (sb-ext:quit) call in its eval chain.

For CCL, is adding --eval '(ccl:quit)' at the end satisfying?

galdor commented 11 months ago

SBCL absolutely exits after loading and evaluating a file with --script. Tested 5s ago with sbcl --script /tmp/test.lisp and a file containing (format t "Hello world!~%"). Same thing with sbcl --no-userinit --non-interactive --eval '(format t "Hello world!~%")' (the fact that it prints this stupid banner is another problem), as it should be.

metayan commented 11 months ago

If we give it what it's asking for, it does what it's supposed to do:

echo |ccl --no-init --batch --quiet --eval '(format t "Hiya!~%")'

;)

phoe commented 11 months ago

Welp, I launched sbcl --script in a terminal, at which point it was reading from standard input, which needed a manual ^D.

I assume then this is a feature request for a ccl --script-like syntax that accepts a filename, loads it, and then exits.

I would expect CCL to exit after all forms passed to --eval options have been evaluated.

I meant sbcl --eval '(format t "Hello world!")' which doesn't quit, apologies for the confusion.

galdor commented 11 months ago

CCL should absolutely have --script to avoid having to provide --no-init --batch --quiet, but --batch should absolutely result in CCL exiting after having processed --load and --eval options (more precisely after code evaluated due to these options has terminated).