Kyle L
Kyle L

Reputation: 820

Running lein repl :headless in the background

Goal: Run lein Headless in the Background

I am trying to run a leiningen REPL headless, without devoting a terminal to it. Namely, I would like to do

$ lein repl :headless &

But after a few seconds bash reports that it has been stopped

$ [2]+  Stopped                 lein repl :headless

Running this in zsh and sh has the same results. Those shells print the signal which is received, SIGTTIN, meaning the process attempted to read from STDIN despite not being the terminal-controlling process.

The following works:

$ bash -c "lein repl :headless &"
$ lein repl :headless </dev/null &

I've taken a look at repl :headless does not work without stdin but I wasn't able to resolve my problem using what was there.


Some other details:

Putting

#!/bin/bash
lein repl :headless & 

into a script test.bash and running ./test.bash also works. But changing the line to lein repl :headless and running ./test.bash & does not.

Running

$ lein repl :headless &
$ disown %1

Also does not work; ps of the process reports that it is terminated.

I also typically run tmux with reattach-to-user-namespace, but I have tried this inside and outside of tmux, and in multiple terminal emulators (iTerm2 and Terminal). If it helps, here are my stty -a settings.

Upvotes: 1

Views: 1538

Answers (1)

Aleph Aleph
Aleph Aleph

Reputation: 5395

lein trampoline repl :headless & will resolve this.

You can read this for an explanation.

Upvotes: 6

Related Questions