X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-6.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Message-ID: <4C8101B0.70000@redhat.com> Date: Fri, 03 Sep 2010 08:09:52 -0600 From: Eric Blake User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100806 Fedora/3.1.2-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.2 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: How 'exec 1<&-; exec 2<&-' work? References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 AT redhat DOT 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