[ 
https://issues.apache.org/jira/browse/HIVE-6758?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14174204#comment-14174204
 ] 

Mohit Sabharwal commented on HIVE-6758:
---------------------------------------

I looked into it a bit, and here's my understanding:
In beeline, for pretty table formatting (which hive cli does not do), we get 
the terminal width (and height) using 
jline.Terminal.setupTerminal().getTerminalWidth(), which [sets terminal 
properties|http://jline.sourcearchive.com/documentation/0.9.94-5/classjline_1_1UnixTerminal_da5160e7ec686c49b8f39e03d986cc2f.html#da5160e7ec686c49b8f39e03d986cc2f]
 by calling stty. 
            
However, when beeline is backgrounded, kernel's terminal driver sends a SIGTTOU 
when stty is called, which if not caught, defaults to "stopping" the process. I 
tried ignoring the signal in beeline:
{code}
Signal.handle(new Signal("TTOU"), SignalHandler.SIG_IGN);
{code}
This puts beeline process state back to "running", though it remains "hung" and 
doesn't resume normal operation. I didn't see anything helpful using jstack.  
Not sure what's happening here, will need some more digging.

However, since we don't care about pretty table formatting in background mode, 
solution proposed by [~qwertymaniac] and [~brocknoland] also works fine. 
Attached patch does that. It essentially sets the terminal type to 
[UnsupportedTerminal|http://jline.sourcearchive.com/documentation/0.9.94-5/classjline_1_1UnsupportedTerminal.html]
 (as opposed to UnixTerminal) which doesn't call stty. 

Alternatively, instead of setting this system property, we could simply not 
initialize a Terminal object if the process is backgrounded. Both approaches 
result in default terminal height and width values. Am going with beeline 
script-only approach.

Would appreciate comments from anyone more familiar with beeline/hive cli. 
Thanks.

> Beeline doesn't work with -e option when started in background
> --------------------------------------------------------------
>
>                 Key: HIVE-6758
>                 URL: https://issues.apache.org/jira/browse/HIVE-6758
>             Project: Hive
>          Issue Type: Improvement
>          Components: CLI
>    Affects Versions: 0.11.0
>            Reporter: Johndee Burks
>            Assignee: Mohit Sabharwal
>
> In hive CLI you could easily integrate its use into a script and back ground 
> the process like this: 
> hive -e "some query" &
> Beeline does not run when you do the same even with the -f switch. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to