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 ?