1
$\begingroup$

How can a Wolframscript be terminated by Ctrl+C without yielding the Interrupt prompt (see e.g. here)? Unfortunately, this self-proclaimed hack causes a segmentation fault in Mathematica 12.3.1 under Linux.

Here is a concrete example where this problem arises and would benefit from a proper solution. Suppose you have a Wolframscript running a server.

#!/usr/bin/env wolframscript
...
SocketListen[{ip, port}, handler];
While[True, Pause[10]];

Pressing Ctrl+C brings up the interrupt prompt. Clearly, the last line of this script - which is supposed to express "wait forever until interrupted" - is also rather ugly.

Can this be properly solved using Tasks? Any suggestions are welcome.

$\endgroup$
4
  • 1
    $\begingroup$ I feel like $BatchInput is supposed to do this, but it doesn't appear to if you set it... $\endgroup$ Commented Sep 4, 2021 at 20:32
  • 1
    $\begingroup$ Or setting $Inspector to nothing, but that also doesn't seem to have an effect. But per the docs these both seem like they should bypass this menu. $\endgroup$ Commented Sep 4, 2021 at 20:39
  • $\begingroup$ Do you need the script to continue after the interrupt or terminate? If the latter then you can kill -9 <pid> from another shell. $\endgroup$ Commented Sep 4, 2021 at 22:56
  • 1
    $\begingroup$ @RohitNamjoshi: It should terminate. I agree that it can be easily done outside the script but I think that there should be a proper way to solve this seemingly simple problem in Wolframscript. $\endgroup$ Commented Sep 4, 2021 at 23:24

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.