Bug 787322 - org.rhq.enterprise.client.ClientMain (remoting-cli) hangs if executed as a service or in the background
Summary: org.rhq.enterprise.client.ClientMain (remoting-cli) hangs if executed as a se...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: RHQ Project
Classification: Other
Component: CLI
Version: 4.2
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
: JON 3.1.0
Assignee: Lukas Krejci
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks: jon310-sprint11, rhq44-sprint11 790859
TreeView+ depends on / blocked
 
Reported: 2012-02-04 00:08 UTC by Larry O'Leary
Modified: 2018-11-26 17:24 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
: 790859 (view as bug list)
Environment:
Last Closed: 2013-09-03 15:10:14 UTC
Embargoed:


Attachments (Terms of Use)

Description Larry O'Leary 2012-02-04 00:08:43 UTC
Description of problem:
CLI can not support non-interactive mode even when a script file or command is provided on the command-line. For example, if system attempts to execute a Remote CLI script as another user or attempts to execute a script as a forked or background process, the CLI script is not executed and the Java process hangs.

This is due to no stdin console. Even when non-interactive options are passed to the CLI, it still insists on an input device (terminal) being attached to the executing process.

Specifically, this is caused by the incorrect initialization of the ClientMain class. During initialization, command-line parameters are parsed and a decision is made to use interaction or non-interactive mode, however, regardless of the command-line arguments and decision, the initializer of ClientMain still sets up the interactive components of jline. Specifically, jline.ConsoleReader having a requirement to read from FileDescriptor.in which is not attached to an actual tty/stty when the JVM is executed as a service (su someuser -c '...') or in the background (java ... .ClientMain &).



Version-Release number of selected component (if applicable):
4.2

How reproducible:
Always

Steps to Reproduce:
1. Execute CLI using -f argument with anything in it:
   ./rhq-cli.sh -u rhqadmin -p rhqadmin -s localhost -t 7080 -f does/not/matter &
  
Actual results:
JVM hangs and background process is 'stopped'

Expected results:
JVM should exit with error indicating file could not be found

Comment 1 Larry O'Leary 2012-02-04 00:11:06 UTC
Thread dump from running process reveals the hung stack:


"main" prio=10 tid=0x00007f7354008800 nid=0x7270 runnable [0x00007f73591f3000]
   java.lang.Thread.State: RUNNABLE
	at java.io.FileInputStream.readBytes(Native Method)
	at java.io.FileInputStream.read(FileInputStream.java:236)
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
	at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
	- locked <0x00000000fe0a3968> (a java.io.BufferedInputStream)
	at jline.UnixTerminal.exec(UnixTerminal.java:303)
	at jline.UnixTerminal.exec(UnixTerminal.java:282)
	at jline.UnixTerminal.stty(UnixTerminal.java:273)
	at jline.UnixTerminal.initializeTerminal(UnixTerminal.java:89)
	at jline.Terminal.setupTerminal(Terminal.java:75)
	- locked <0x00000000ee250af8> (a java.lang.Class for jline.Terminal)
	at jline.Terminal.getTerminal(Terminal.java:26)
	at jline.ConsoleReader.<init>(ConsoleReader.java:191)
	at jline.ConsoleReader.<init>(ConsoleReader.java:186)
	at jline.ConsoleReader.<init>(ConsoleReader.java:174)
	at org.rhq.enterprise.client.ClientMain.<init>(ClientMain.java:149)
	at org.rhq.enterprise.client.ClientMain.main(ClientMain.java:103)

Comment 2 Charles Crouch 2012-02-15 13:07:37 UTC
Lukas, can you investigate this.

Comment 3 Lukas Krejci 2012-02-15 17:28:43 UTC
This has been fixed in master tracked by bug 790859.

Comment 4 Mike Foley 2012-03-26 18:52:38 UTC
Documenting the verification


[mfoley@foleymonsterbox1 bin]$ ./rhq-cli.sh -u rhqadmin -p rhqadmin -s localhost -t 7080 -f ./test.js &
[1] 26675
[mfoley@foleymonsterbox1 bin]$ Remote server version is: 4.4.0-SNAPSHOT (94f6790)
Login successful
./test.js (No such file or directory)

[1]+  Done                    ./rhq-cli.sh -u rhqadmin -p rhqadmin -s localhost -t 7080 -f ./test.js
[mfoley@foleymonsterbox1 bin]$

Comment 5 Heiko W. Rupp 2013-09-03 15:10:14 UTC
Bulk closing of old issues in VERIFIED state.


Note You need to log in before you can comment on or make changes to this bug.