1

I want to configure arara to launch my PDF reader after compilation. I can do this with the following custom rule:

!config
identifier: evince
name: evince
commands:
- name: Open in Evince
  command: >
    @{
      name = 'build/'+getBasename(reference.getName()) + '.pdf';
      return getCommand(['evince', name])
    }
arguments: []

However when using this rule, arara just hangs until I close the PDF reader again:

(LaTeXmk) Tool LaTeXmk .................................. SUCCESS
(evince) Open in Evince ................................. 

Appending & to the command just makes evince try to open the file &. I tried various combinations of nohup, setsid, coproc and disown both directly from this rule, or by indirectly calling evince from a bash script, but nothing changes. Arara refuses to continue unless I stop my PDF reader.

Any suggestions on how to make arara continue after spawning the PDF reader as a background process?

6
  • 1
    If Evince is your default pdf reader maybe you can use xdg-open name instead? I think that returns immediately.
    – Marijn
    Aug 4, 2022 at 11:53
  • While this correctly opens the PDF with evince, it still doesn't return. Aug 4, 2022 at 12:04
  • 1
    Indirectly calling evince from bash script should work as long as you put the & inside the bash script itself. What do you write in the bash script exactly?
    – user202729
    Aug 4, 2022 at 12:48
  • I wrote #!/bin/bash followed by evince $1 & And I would expect that to work. My only success is when I used coproc evince $1 disown. This successfully returns, but also makes evince try to open a file called disown and give a pop up with an error. (Adding an & before disown does not work). The problem is also not with evince; if I replace evince with okular I have the same issue. Aug 4, 2022 at 15:12
  • 1
    Maybe put an explicit return 0 at the end of the script? I'm not sure how Arara checks that a command is finished, possibly setting the return value would help.
    – Marijn
    Aug 4, 2022 at 15:29

1 Answer 1

2

In the end I was able to solve it by calling the following bash script (replacing evince above by a call to this script):

#!/bin/bash
evince $1 > /dev/null &
exit 0

What is interesting is that both redirecting output to /dev/null and returning with exit 0 are essential. My guess is that this a bug in arara, but I will try to reproduce it on a different machine before reporting it.

3
  • Hello! It's not a bug, this behaviour is by design: arara always waits for the process to finish... Aug 4, 2022 at 17:57
  • 1
    I still think it's a bug. Spawning a background process and exiting with code 0 should allow arara to continue. The necessity for output to be redirected to /dev/null, and explicitly calling exit 0 is unexpected. The problem isn't necessarily with arara, but I certainly think that this behavior is strange. Aug 4, 2022 at 19:58
  • The team is keen on discussing about this, thanks a lot for raising it up. :) Just a note: it might be a surprising behaviour, but it's expected, so it's not a bug, as we explicitly wait for process termination. We will see what can be done for future versions. :) Aug 5, 2022 at 8:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .