]> granicus.if.org Git - python/commitdiff
Added flock().
authorGuido van Rossum <guido@python.org>
Thu, 23 May 1996 22:56:38 +0000 (22:56 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 23 May 1996 22:56:38 +0000 (22:56 +0000)
Modules/fcntlmodule.c

index 229958532da05ed497ba9f17c29a226e793b9c16..d2efd60311ab7fb540e22318547a3e663c9cdf17 100644 (file)
@@ -128,11 +128,40 @@ fcntl_ioctl(self, args)
 }
 
 
+/* flock(fd, operation) */
+
+static object *
+fcntl_flock(self, args)
+       object *self; /* Not used */
+       object *args;
+{
+       int fd;
+       int code;
+       int ret;
+       FILE *f;
+
+       if (!getargs(args, "(ii)", &fd, &code))
+               return NULL;
+
+       BGN_SAVE
+       ret = flock(fd, code);
+       END_SAVE
+       if (ret < 0) {
+               err_errno(IOError);
+               return NULL;
+       }
+       INCREF(None);
+       return None;
+}
+
+
+
 /* List of functions */
 
 static struct methodlist fcntl_methods[] = {
        {"fcntl",       fcntl_fcntl},
        {"ioctl",       fcntl_ioctl},
+       {"flock",       fcntl_flock},
        {NULL,          NULL}           /* sentinel */
 };