I am currently working on modernizing (was made on Trusty 14.04, modernizing for Bionic 18.04) a python script that uses curses to create a menu for a user. During the initial launch of the script before the actual UI is displayed there is a line:


(The documentation for this command can be found here) This line is preceded by a curses.initscr() so there should be a valid terminal to receive input from. The problem is that this exact line causes the script to be backgrounded and you have to fg the process to continue the execution. After the fg, the delay specified in the halfdelay will take place and then the script will continue normally which suggests the backgrounding takes place before actually waiting for any characters. For reference, the script works perfectly fine in Ubuntu 14.04, so I am inclined to say it is a problem due to a change in the way getty works or a change in behaviour from upstart to systemd. I have found that replacing the line halfdelay with curses.cbreak() instead also causes it to be backgrounded. Since halfdelay essentially causes the terminal to switch in to cbreak mode, that suggests to me that this is what is causing the issue. I have been unable to find anyone online having an even remotely similar issue so any help would be appreciated.



The issue was that curses was trying to hijack tty1 (which was already in use) and therefore in order to prevent the current terminal from being hijacked the OS backgrounds the problem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.