Article View: es.comp.os.linux.programacion
Article #18470Re: Lock files
From: *puntero_loco
Date: Thu, 02 Sep 1999 00:00
Date: Thu, 02 Sep 1999 00:00
36 lines
1798 bytes
1798 bytes
El Wed, 01 Sep 1999 16:37:45 GMT, Colin Mahoney <cmahoney@readysoft.es> escribi๏ฟฝ:
|I want to create a lock file while I open a file, process it, write
|out the new file then overwrite the old one with the new one.
|
|What's the standard way to do this? I have no previous experience with
|linux, so thanks for any help.
|
|Colin Mahoney
#include <stdio.h>
#include <unistd.h>
int main(){
status = fopen("/tmp/.lock","r");
if (status != NULL) // Check if lockfile already exist
{
fprintf(stderr,"Lock file already exist in /tmp/.lock\n");
fclose(status);
exit(1);
}
lock = fopen("/tmp/.lock","w"); // lockfile don't exist, create one
[HERE YOU OPEN YOUR FILE, PROCESS IT
, WRITE, ETC]
fclose(lock);
ulink("/tmp/.lock"); // Delete the lockfile
}
For more references write on the shell "info libc" (without the quotes).
--
/-----------------------------\
| *puntero_loco |
| Debian 2.1 Slink |
| jajsNOSPAM@retemail.es |
| http://personal5.iddeo.es/jajs|
\-----------------------------/
Technical Details
Message-ID:
<g6fkq7.362.ln@127.0.0.1>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<37cf55e2.15291552@news.readysoft.es>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f86c8,3792f127a66f6c06 X-Google-Attributes: gidf86c8,public From: jajs@SPAMNOretemail.es (*puntero_loco) Subject: Re: Lock files Date: 1999/09/02 Message-ID: <g6fkq7.362.ln@127.0.0.1> X-Deja-AN: 520316420 Distribution: es Content-Transfer-Encoding: 8bit References: <37cf55e2.15291552@news.readysoft.es> Content-Type: text/plain; charset=iso-8859-1 X-Complaints-To: newsmanager@rediris.es X-Trace: batcher.rediris.es 936303109 15072 62.81.100.234 (2 Sep 1999 20:11:49 GMT) Organization: Tarifa plana para todos YA! Mime-Version: 1.0 User-Agent: slrn/0.9.5.3 (UNIX) NNTP-Posting-Date: 2 Sep 1999 20:11:49 GMT Newsgroups: es.comp.os.linux.programacion