[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash uses tmp files for inter-process communication instead of pipes

From: Greg Wooledge
Subject: Re: bash uses tmp files for inter-process communication instead of pipes?
Date: Tue, 7 Oct 2014 13:41:23 -0400
User-agent: Mutt/

On Tue, Oct 07, 2014 at 09:54:21AM -0700, Linda Walsh wrote:
> Chet Ramey wrote:
> >It's syslog.  Some vendors integrated patches that log all shell commands
> >to syslog.
> >
> No... that wasn't syslog, it was strace in another terminal where I attached
> the bacsh that was doing the various types of data transfer (pipes, process 
> subst)
> assignment... etc)....

Chet is saying that your vendor's version of Bash may have been patched
to make client-side calls to syslog(2), and this might be what you are
seeing in your strace.

If it turns out this is what's causing your problem, then you'll have
some tough choices to make.

> Um... it used a socket.. to transfer *i^Ht^H*SOMETHING,
> then it uses a tmp file on top of that:
> rt_sigaction(SIGINT, {0x4320b1, [], SA_RESTORER|SA_RESTART, 0x30020358d0}, 
> {0x4320b1, [], SA_RESTORER|SA_RESTART, 0x30020358d0}, 8) = 0
> open("/tmp/sh-thd-110678907923", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0600) = 3
> write(3, "one two three four", 18)      = 18
> write(3, "\n", 1)                       = 1
> open("/tmp/sh-thd-110678907923", O_RDONLY) = 4
> close(3)                                = 0
> unlink("/tmp/sh-thd-110678907923")      = 0

The opens & writes & close & unlink are straight out of redir.c function
here_document_to_fd.  So that's bash opening the temp file for the
here document.  Any socket stuff before that could be from a vendor
patch, or a child process, or something else other than vanilla bash.

> I have neither TMP nor TMPDIR set at this point.  I don't
> think TMP or TMPDIR is set in the runscript at boot, but the script could 
> be inheriting
> a value from the bootup-infrastructure environment.

You could always add some debugging lines to the script to find out.

> ----the script in question is "assign_netif_names" run fairly late.
> But if I Break in on 'B', I get control before S01boot.  If I run the 
> command
> manually at that point, **it works**.   Only when I'm letting it boot 
> normally, does
> it hit this problem.


> >>>/etc/init.d/boot.assign_netif_names#193(get_net_IFnames_hwaddrs)> echo 
> >>>eth5 a0:36:9f:15:c9:c2
> /etc/init.d/boot.assign_netif_names: line 204: cannot create temp file for 
> here-document: No such file or directory

This error message definitely indicates the failure of bash internal
function here_document_to_fd (in redir.c).  The question is exactly
what failed, and why.

I've given you a workaround for the immediate problem you're seeing,
so you could use that until you are able to diagnose the underlying
problem and find out why this particular feature is failing.

To reiterate (and expanding a bit, because I omitted a few details
in the previous message):

declare -A map1 map2 # etc.
create_maps() {
    cd /some/place || return
    for ifname in ...; do
cd "$here" || exit

Honestly, I don't understand why you are changing directory at all.
If it's just for the convenience of shortening the hwaddr=... command,
personally I'd drop the cd, stick the full path into the hwaddr=... line,
and thereby reduce the complexity another notch.  But if you think the
cd is needed, then drop the subshell, and add the additional checking
and final "cd back to where I started" to compensate (as I've shown).

The subshell is what's causing all of your grief (the serialization
and deserialization), so definitely drop that.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]