Suspending the Linux CLI Session (workaround for no Ctrl-Z)

Using Dyalog under 'nixes

Suspending the Linux CLI Session (workaround for no Ctrl-Z)

Postby baingeenej on Tue Mar 21, 2023 4:06 pm

This is just some notes for posterity (18.2):

Typically, in CLI applications on Linux such as editors or REPLs, typing Ctrl-Z will temporarily suspend the editor or REPL and drop you back into the parent shell. However, the Dyalog CLI session on Linux doesn't do this; typing Ctrl-Z directly inserts a SUB character into the session.

Under the hood, Ctrl-Z defaults to sending SIGSTP to the foreground process, so as a workaround we can do the same:

Code: Select all
'getpid' ⎕SE.getpid 'I4 libc.so.6|getpid'     ⍝ pid_t getpid(void)
  'kill' ⎕SE.kill   'I4 libc.so.6|kill I4 I4' ⍝ int kill(pid_t pid, int sig)
⎕SE.⎕FX 'susp;sigstp' 'getpid kill sigstp←20'


After which we can then type ⎕se.susp to get the behavior of Ctrl-Z. Note that pid_t is translated into I4 above because GNU libc specifies pid_t to be an int: https://www.gnu.org/software/libc/manua ... ation.html.
baingeenej
 
Posts: 4
Joined: Fri May 13, 2022 9:33 am

Return to UNIX and Linux

Who is online

Users browsing this forum: No registered users and 1 guest