Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to check if a file is open in editor? Post 303005559 by Scott on Thursday 19th of October 2017 03:55:53 PM
Old 10-19-2017
No one's mentioned lock files and race conditions yet. Go us!
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Unable to open files in VI editor

Hi, I unable to open any file using Vi editor,constantly getting the following error, vi log.log *** glibc detected *** malloc(): memory corruption: 0x081af510 ** uname -a Linux sekac092 2.6.5-7.244-bigsmp #1 SMP Mon Dec 12 18:32:25 UTC 2005 i686 athlon i386 GNU/Linux Also Note ls... (8 Replies)
Discussion started by: ennstate
8 Replies

2. Shell Programming and Scripting

How to give permissions to an open file in vi editor?

Hi all, I have a shell script that i started editing, only in the midst of which i tried to save the changes i found that the file wasnt been provided with write/execute permissions. I later have redone the changes and saved the file- Just curious to know if there was any command wherein... (5 Replies)
Discussion started by: Pankajakshan
5 Replies

3. UNIX for Advanced & Expert Users

getting error when open vi editor

helo I install my product for koren language I m uisng RHEL -4 operating system now problem is whenever I open any file vi filename I got following error on the screen E557: Cannot open termcap file 'vt100' not known. Available builtin terminals are: builtin_ansi ... (1 Reply)
Discussion started by: amitpansuria
1 Replies

4. UNIX for Dummies Questions & Answers

How to open file in VI Editor at a specific line?

i have following query e.g i want the VI Editor cursor at line number N instead of 0 while opening the file from unix prompt. vi filename ?????? Can anyone help? (4 Replies)
Discussion started by: skyineyes
4 Replies

5. Shell Programming and Scripting

avoid open file to check field.

Hi Everyone, # cat a.txt 94,aqqc,62345907, 5,aeec,77, # cat 1.pl #!/usr/bin/perl use strict; use warnings; use Date::Manip; open(my $FA, "/root/a.txt") or die "$!"; while(<$FA>) { chomp; my @tmp=split(/\,/, $_); if (index($tmp, "qq") ne -1) { ... (4 Replies)
Discussion started by: jimmy_y
4 Replies

6. Solaris

Before I delete any file in Unix, How can I check no open file handle is pointing to that file?

I know how to check if any file has a unix process using a file by looking at 'lsof <fullpath/filename>' command. I think using lsof is very expensive. Also to make it accurate we need to inlcude fullpath of the file. Is there another command that can tell if a file has a truely active... (12 Replies)
Discussion started by: kchinnam
12 Replies

7. UNIX and Linux Applications

Notepad++ hang when open file edited in other text editor

Hi, I would like to ask about the notepad++ text editor application, Although there are alternative and more great text editor in linux (gedit, geany, jedit) im still using the notepad++ sometimes cause for some of my own reason one of those is the minimalist text(what i mean is notepad++ has a... (2 Replies)
Discussion started by: jao_madn
2 Replies

8. UNIX for Dummies Questions & Answers

Vi editor will not open new to UNIX. help please.

vi: syntax error at line 1: `)' unexpected when I try to vi into the /etc/vfstab, the return gives me the above error. how can resolve this so that I can have access into vi. (6 Replies)
Discussion started by: dovestar
6 Replies

9. Shell Programming and Scripting

Not able to read .csv file until open in vi editor

Hi, I am facing a problem regarding .csv file, my script does not read .csv file and if i open this file in vi editor and perform :wq option then only my script reads the .csv file. Thanks (5 Replies)
Discussion started by: ranabhavish
5 Replies

10. Shell Programming and Scripting

To check if a file is open and in use (logs are being written to it)

Hello Experts, I need to write a shell script to check if a file is open and something is being written to it. I want to know how OS handles it. I checked with lsof command but it is not working. For a test I did this. while true; do echo `date` >>abc.txt; done then I checked lsof |... (5 Replies)
Discussion started by: shekhar_4_u
5 Replies
LOCKMAIL(1)						      Double Precision, Inc.						       LOCKMAIL(1)

NAME
lockmail - create mail lock files SYNOPSIS
lockmail [-r] [-t timeout] {lockfile} {program} [argument...] DESCRIPTION
lockmail is a helper utility for working with mailbox files. Mailbox files must be locked to prevent other applications from modifying the mailbox at the same time. Different system use different locking conventions. lockmail uses two of the most common locking mechanisms in use, which should work reliably on most systems. lockfile is the pathname to an existing mailbox file. By default, lockmail tries to lock the mailbox every five seconds (if the mailbox is already locked), and will give up after three minutes. After the mailbox is successfully locked, lockmail runs program as a child process, with any optional arguments. When program terminates, lockmail removes the mailbox lock, and terminates itself. OPTIONS
-r If a regular lock fails, try a read-only lock. Use this option to lock mailbox files in a read-only directory. -t timeout If the lock attempt fails, try again for up to timeout seconds. The actual timeout is rounded up to the next five second interval (a lock attempt is tried every five seconds). DESCRIPTION
This section briefly describes the locking mechanism used by lockmail. lockmail uses three different locking conventions in order to maximize compatibility with other mail software: C-Client folder locks, dot-locks, and file locks. C-Client folder locks Mail software based on the C-Client library creates lock files named /tmp/.dddddd.iiiiii. Here, dddddd and iiiiii are the device number and the inode number of the mailbox file (the st_dev and st_ino fields in the inode), in hexadecimal. If the process ID saved in the C-Client folder lock file is not valid, lockmail concludes that it's a stale lock file, and will remove it. Note A race condition exists where a C-Client process is killed after it creates a lock file, but before saving its process ID in the lock file. The race window is very small, but it exists. The C-Client library does not appear to ever clear out the lock file. lockmail attempts to resolve this race condition by deleting zero-length lock files that are at least five minutes old. dot-locks lockmail also creates, and honors dot-lock files. Dot-lock files are first created as temporary files, then linked to lockfile.lock. The link operation fails if the dot-lock file already exists. lockmail uses an enhanced method of dot-locking, where its process ID, and the name of the server where lockmail is running is also saved in its dot-lock file. If the operation fails due to an existing dot-lock file that was created by another lockmail process on the same server, and the process ID no longer exists, this stale dot-lock file is removed immediately. In all other situations a dot-lock file older than five minutes is considered stale, and removed. Note A failure to create a dot-lock file is silently ignored if the reason for the failure is because lockmail does not have the write permission in the dot-lock file's directory. The incoming mail spool directory (usually /var/mail) typically does not have global write permissions, so the attempt to create the dot-lock file in the spool directory will fail, and lockmail will be content with using file-locking only. File locks The final locking mechanism lockmail uses is the operating system's file locking facility. If lockmail fails to obtain all three locks, lockmail will sleep for five seconds and try again. The only exception is a failure to create a dot-lock because of no write access to the dot-lock file's directory, which is ignored. If lockmail still fails to obtain all required locks in the amount of time specified by the -t option (or its default value), lockmail will terminate with the EX_TEMPFAIL exit code. lockmail runs program after obtaining the last file lock, waits until program terminates, and releases all locks. program must terminate before any of the locks obtained by lockmail expire, and are considered stale. lockmail will then terminate with the same exit code as program. EXIT STATUS
lockmail terminates with the same exit status as program lockmail terminates with the EX_TEMPFAIL exit status if it was unable to obtain a lock, or if program was killed by a signal. SEE ALSO
maildrop(1)[1], sendmail(8). AUTHOR
Sam Varshavchik Author NOTES
1. maildrop(1) [set $man.base.url.for.relative.links]/maildrop.html Courier Mail Server 08/30/2011 LOCKMAIL(1)
All times are GMT -4. The time now is 10:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy