This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: How 'exec 1<&-; exec 2<&-' work?
- From: Eric Blake <eblake at redhat dot com>
- To: cygwin at cygwin dot com
- Date: Fri, 03 Sep 2010 08:09:52 -0600
- Subject: Re: How 'exec 1<&-; exec 2<&-' work?
- References: <i5qcns$7u6$1@dough.gmane.org>
On 09/03/2010 02:47 AM, Oleksandr Gavenko wrote:
I intuitively change command to
exec 1<&-; exec 2<&-; XWin -multiwindow &
I really don't understand what magic exec do.
How could it be intuition if you don't know what it does? A better
description would be calling it what it was to you at the time - black
magic copied from some online example you found.
Can anyone point me?
'exec' with just file redirections makes those redirections affect the
current shell and all subsequent processes started by the shell. 1<&-
is a POSIX-mandated redirection for closing stdout; likewise 2<&- for
closing stderr. By closing stdout and stderr before starting XWin, you
are making it so that XWin no longer ties up your terminal.
By the way, you could run this instead:
XWin -multiwindow >&- 2>&- &
and get the same effect without the 'exec'.
And none of this is cygwin-specific.
--
Eric Blake eblake@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple