Re: [patch] file locking, v3



On Tue, Jul 16, 2002 at 02:15:22PM +0200, Floris Kraak wrote:
+        if (is_locked(file_name)) {
+           gnumeric_io_error_info_set(io_context, error_info_new_str(_("File locked by another 
process!")));
+           return;
+        }

+gchar* create_locking_string(const gchar* filename)
+{
+    gchar *lockstr;
+    char hostname[256];
+    long pid;
+    
+    gethostname(hostname, 255);
check for failure please.

+    hostname[255] = 0;
+    pid = (long) getpid();
+    
+    lockstr = g_strdup_printf("%s:%ld", hostname, pid);    
+    return lockstr;
+}
The lockfile contains more information than you are using.  It would
be nice if the message displayed it.  Adding the ability to break a
potentially stale lock will require some extension to the io_context
framework (similar in form to the password entry), so that is not
necessary in the first pass.

I'll suggest doing something a touch more complicated and lifting
the filename generation from vim.  It should not be too tough to
pull out (it appears to live mostly in memline.c and io_file.c).
This will give us a huge amount of pre-tested portability.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]