Euphoria Ticket #936: Background programs hang on exit

OS: Linux or OSX

Interpreted or compiled programs that are run in the background (using &) or using Ctrl+Z and "bg" will hang on exit. By entering "fg" in the same terminal, the program will unfreeze and exit normally. When gdb is attached to the process, the backtrace is as follows:

Program received signal SIGTTOU, Stopped (tty output). 
0x00007fe5d96586b0 in __GI_tcsetattr (fd=0, optional_actions=<optimized out>,  
    termios_p=0x8c2cd0 <savetty>) at ../sysdeps/unix/sysv/linux/tcsetattr.c:87 
87	../sysdeps/unix/sysv/linux/tcsetattr.c: No such file or directory. 
(gdb) bt 
#0  0x00007fe5d96586b0 in __GI_tcsetattr (fd=0,  
    optional_actions=<optimized out>, termios_p=0x8c2cd0 <savetty>) 
    at ../sysdeps/unix/sysv/linux/tcsetattr.c:87 
#1  0x0000000000602f80 in Cleanup () 
#2  0x0000000000605aa5 in UserCleanup () 
#3  0x00000000005a565e in _39Quit (_ctl_24245=<optimized out>,  
    _errcode_24246=0) at GtkEngine.c:3955 
#4  0x00000000006028cc in general_call_back () 
#5  0x00007fe5da2630c7 in ?? () 
#6  0x00007fe5da263090 in ?? () 
#7  0x0000000000000002 in ?? () 
#8  0x00007fe5d72d9a93 in g_hash_table_lookup () 
   from /lib/x86_64-linux-gnu/ 
#9  0x000000000156baa0 in ?? () 
#10 0x0000000000000000 in ?? () 

This appears to be caused by the call to tcsetattr in EndGraphics() in be_machine.e. I have tested wrapping the tcsetattr in "if (have_console)" and recompiled Euphoria from source, and it seems to fix the problem. Here's the patch:

diff -r 16462e686646 source/be_machine.c 
--- a/source/be_machine.c	Wed Oct 07 21:27:52 2015 -0300 
+++ b/source/be_machine.c	Thu Oct 08 14:44:44 2015 -0700 
@@ -343,7 +343,9 @@ 
 	SetConsoleMode(console_output, orig_console_mode); // back to normal 
 #ifdef EUNIX 
-	tcsetattr(STDIN_FILENO, TCSANOW, &savetty); 
+	if (have_console) { 
+		tcsetattr(STDIN_FILENO, TCSANOW, &savetty); 
+	} 


Type: Bug Report Severity: Normal Category: Other
Assigned To: unknown Status: New Reported Release: 4.1.0
Fixed in SVN #: View VCS: none Milestone:


Quick Links

User menu

Not signed in.

Misc Menu