How to disable file descriptors in Bash scripts

Source: Internet
Author: User

In the Bash script, how does one close the file descriptor and encounter A problem when writing A Bash script tonight? This script is used to start A program B, which is called by another program, the result shows that many file descriptors opened by process A (such as Socket) exist in the newly started process B ). So I decided to close them in the script, because for the sake of simplicity, I used system () in program A to start the script. The script for disabling file descriptors is added as follows: www.2cto.com #! /Bin/sh cd $ (dirname "$0") | exit 1 exec 3> &-exec 4> &-. /rbtunnel "$ @" & # sleep 1 the key point here is to close the code of the file Description: exec fd> &-or: exec fd <&-where fd is the number of the file descriptor, and the file descriptor can be viewed in Linux Through lsof-c rbtunnel.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.