Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8087567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:49:06+00:00 2026-06-05T18:49:06+00:00

In a bash script in Linux, I am using flock [the command flock, not

  • 0

In a bash script in Linux, I am using flock [the command flock, not the system call flock()] to implement file locking thereby guarding concurrent access against a shared resource [which is a file in tmpfs].

I have trap handlers to handle abnormal termination of my script:
trap "{ rm -rf $LOCK ; rm -rf $TMPFS_FILE; exit 255; }" SIGINT SIGTERM

where $LOCK is my lock file and $TMPFS_FILE is my shared resource.

My question is do I need to explicitly do a file unlock as well ? Or does Linux do it for me upon all program termination [both voluntary termination as well as forced] scenarios ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:49:07+00:00Added an answer on June 5, 2026 at 6:49 pm

    From man 1 flock:

    -u, –unlock

              Drop  a  lock.   This  is  usually not required, since a lock is
              automatically dropped when the file is closed.  However, it  may
              be  required  in special cases, for example if the enclosed com‐
              mand group may have forked a background process which should not
              be holding the lock.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How we run php script using Linux bash? php file test.php test.php contains: <?php
I am launching a Python script from the command line (Bash) under Linux. I
How to schedule a task to linux server system using php script? For example,
I’ve a bash script I’ve been using for a Linux environment but now I
Linux bash script: function Print() { echo $1 } Print OK This script runs
Linux bash script: #!/bin/bash function Print() { echo $1 } var=* Print $var Execution
In Bash script, what is the difference between the following snippets? 1) Using single
I am using a bash script and am trying to cycle through the modules
I have a bash script that runs (something like) the following command: vim -E
I'm writing a bash script, and I'd like to monitor file changes into a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.