Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assignment of the result of a subprocess to a variable hangs #2294

Closed
areman opened this issue Jul 6, 2017 · 4 comments
Closed

assignment of the result of a subprocess to a variable hangs #2294

areman opened this issue Jul 6, 2017 · 4 comments

Comments

@areman
Copy link

areman commented Jul 6, 2017

> ver
Microsoft Windows [Version 10.0.15063]
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.2 LTS
Release:        16.04
Codename:       xenial

I installed the oracle instant client

sudo apt-get install -y alien
alien -i oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm 
alien -i oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86_64.rpm

sqlplus itself works fine. I can connet to databases without any problem.

But when I try to assign the result of a sqlplus command to a variable the bash hangs.

value=$( sqlplus -s user/password@DB <<SQL
select 1 from dual;
exit;
SQL
)

The sqlplus call itself finished successful and the subshell finished. But something hangs and the calling bash doesn't get the "focus" back.

Without a variable assignment it works.

( sqlplus -s user/password@DB <<SQL
select 1 from dual;
exit;
SQL
)

It seems the problem has something to do with the output streams. Add a simple pipe and it works.

echo $( sqlplus -s user/password@DB <<SQL 2>&1 | cat
select 1 from dual;
SQL
)
@ethanherbertson
Copy link

I see something very similar happening in Perl.

Doing something like

my $output = `sqlplus -S /nolog \@define.sql`;

causes a "hang", where the statement never finishes executing. However, doing something like

exec `sqlplus -S /nolog \@define.sql`;

behaves correctly.

If I do a "streaming" version of the same thing, I can confirm that the sqlplus command itself does in fact complete:

open my $cmd_fh, '-|', 'sqlplus -S /nolog @define.sql 2>&1 && echo \'done\'';
print "Line: $_" while (<$cmd_fh>);
close $cmd_fh;

prints:

→ perl thing.pl
Line: DEFINE _SQLPLUS_RELEASE = "1202000100" (CHAR)
Line: done

And then hangs.

@therealkenc
Copy link
Collaborator

Not sure how this one got lost in the noise and wasn't marked need-repro from the get-go. If you are experiencing the problem in 1809 (aka 17763 aka RS5 aka October 2018 update) you can try rebooting the issue following CONTRIBUTING.md with particular attention to pasteable CLI repro steps from clean install and an strace log.

@ethanherbertson
Copy link

ethanherbertson commented Oct 18, 2018

Not sure how this one got lost in the noise and wasn't marked need-repro from the get-go. If you are experiencing the problem in 1809 (aka 17763 aka RS5 aka October 2018 update) you can try rebooting the issue following CONTRIBUTING.md with particular attention to pasteable CLI repro steps from clean install and an strace log.

I can't get away with clean-slating my current setup, but I'll see what I can do.

@therealkenc
Copy link
Collaborator

therealkenc commented Oct 19, 2018

You can generally fake it; what's important is the repro and the strace, noting that the probability of the issue getting attention is inversely proportional to the number of steps. How "clean" is relative. Another alternative is to install 16.04 from the Store (if you are running 18.04) or vice-verse. The Ubuntu version isn't going to make a difference, given the OP was from last year. [ed Notwithstanding any repro to go on I think this might be #2786 related so trying the October 2018 Update will matter.] Bonne chance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants