flock

cwarlich

Neuer User
Mitglied seit
10 Nov 2007
Beiträge
115
Punkte für Reaktionen
0
Punkte
0
Hallo,

ich sehe gerade, dass es kein flock auf der FB gibt. Ich habe auch nichts in den Freetz-Paketen gefunden. Hab' ich da was übersehen?

Ich muss mit einem Prozess Daten in eine Datei schreiben und mit einem anderen Prozess die Daten lesen und dann löschen. Eine Pipe geht nicht, weil der Speicher persistent sein muss.

Oder gibt es eine Alternative?

Viele Grüße,

Chris
 
ich sehe gerade, dass es kein flock auf der FB gibt. Ich habe auch nichts in den Freetz-Paketen gefunden.
Hier ein Paket (Patch) für flock mit Freetz:
Code:
diff -Naur '--exclude=.*' make/flock.orig/Config.in make/flock/Config.in
--- make/flock.orig/Config.in	1970-01-01 01:00:00.000000000 +0100
+++ make/flock/Config.in	2012-05-05 22:03:38.000000000 +0200
@@ -0,0 +1,5 @@
+config FREETZ_PACKAGE_FLOCK
+	bool "flock 0.1 (binary only)"
+	default n
+	help
+		flock - An instructive file locking tool.
diff -Naur '--exclude=.*' make/flock.orig/flock.mk make/flock/flock.mk
--- make/flock.orig/flock.mk	1970-01-01 01:00:00.000000000 +0100
+++ make/flock/flock.mk	2012-05-05 22:02:37.000000000 +0200
@@ -0,0 +1,25 @@
+$(call PKG_INIT_BIN, 0.1)
+$(PKG)_BINARY:=$($(PKG)_DIR)/$(pkg)
+$(PKG)_TARGET_BINARY:=$($(PKG)_DEST_DIR)/usr/bin/$(pkg)
+
+$(PKG_LOCALSOURCE_PACKAGE)
+$(PKG_CONFIGURED_NOP)
+
+$($(PKG)_BINARY): $($(PKG)_DIR)/.configured
+	$(SUBMAKE) -C $(FLOCK_DIR) \
+		CC="$(TARGET_CC)" \
+		CFLAGS="$(TARGET_CFLAGS)"
+
+$($(PKG)_TARGET_BINARY): $($(PKG)_BINARY)
+	$(INSTALL_BINARY_STRIP)
+
+$(pkg)-precompiled: $($(PKG)_TARGET_BINARY)
+
+$(pkg)-clean:
+	-$(SUBMAKE) -C $(FLOCK_DIR) clean
+	 $(RM) $(FLOCK_DIR)/.configured
+
+$(pkg)-uninstall:
+	$(RM) $(FLOCK_TARGET_BINARY)
+
+$(PKG_FINISH)
diff -Naur '--exclude=.*' make/flock.orig/Makefile.in make/flock/Makefile.in
--- make/flock.orig/Makefile.in	1970-01-01 01:00:00.000000000 +0100
+++ make/flock/Makefile.in	2012-05-05 22:04:04.000000000 +0200
@@ -0,0 +1,3 @@
+ifeq ($(strip $(FREETZ_PACKAGE_FLOCK)),y)
+PACKAGES+=flock
+endif
diff -Naur '--exclude=.*' make/flock.orig/src/flock.c make/flock/src/flock.c
--- make/flock.orig/src/flock.c	1970-01-01 01:00:00.000000000 +0100
+++ make/flock/src/flock.c	2012-05-05 21:45:23.000000000 +0200
@@ -0,0 +1,292 @@
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/uio.h>
+#include <string.h>
+
+#ifndef IN_BSD_LAND
+/* This is for flock() in Linux */
+#include <sys/file.h>
+#endif
+
+void hang_out(int t)
+{
+  int i = t;
+
+  /* There is a cleaner way to do this... It does not really matter. I just
+     do not want it to print the number we are starting with, and do not want
+     it to print 0. */
+  if(t >= 1)
+    sleep(1);
+
+  while(--i)
+  {
+    fprintf(stderr, "%d", i);
+    sleep(1);
+  }
+}
+
+int main(int argc, char *argv[])
+{
+  int f, ff;     /* File and FlagFile */
+  ssize_t rw;
+  char buf[16];
+
+  /* ======================================================================= */
+  if(argc != 2)
+  {
+    fprintf(stderr, "Unable to determine what mode I am in.\nExiting.\n");
+    return(1);
+  }
+
+  if((0 == strcmp(argv[1], "--help")) ||
+     (0 == strcmp(argv[1], "-h")) ||
+     (0 == strcmp(argv[1], "-H")))
+    {
+      printf("flock - An instructive file locking tool.\n");
+      printf("        Open two windows, and in the first window run \"flock first\", then in\n");
+      printf("        the second window run \"flock second\". The first will hold open the\n");
+      printf("        file with a shared lock for 10 seconds. The second will open the file\n");
+      printf("        with a shared lock then attempt to convert the lock to exclusive. The\n");
+      printf("        second will block waiting for the first to release the lock (when it\n");
+      printf("        closes the file). Remember: flock blocks!\n");
+      return(0);
+    } 
+
+  /* ======================================================================= */
+  if(0 == strcmp(argv[1], "first"))
+  {
+    fprintf(stderr, "Removing any pre-existing flag file...");
+    remove("flag.file");
+    fprintf(stderr, "Done.\n");
+
+#ifdef IN_BSD_LAND
+    fprintf(stderr, "Opening file with exclusive lock...");
+    if(-1 == (f = open("delete.me",
+		       O_CREAT | O_WRONLY | O_APPEND | O_EXLOCK,
+		       S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH)))
+      {
+	fprintf(stderr, "Failed.\n");
+	return(1);
+      }
+    fprintf(stderr, "Done.\n");
+#else
+    fprintf(stderr, "Opening file...");
+    if(-1 == (f = open("delete.me",
+		       O_CREAT | O_WRONLY | O_APPEND,
+		       S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH)))
+      {
+	fprintf(stderr, "Failed.\n");
+	return(1);
+      }
+    fprintf(stderr, "Done.\n");
+
+    fprintf(stderr, "Setting an exclusive lock on the file...");
+    if(-1 == flock(f, LOCK_EX))
+      {
+	fprintf(stderr, "Failed.\n");
+	return(1);
+      }
+    fprintf(stderr, "Done.\n");
+#endif
+
+
+
+    fprintf(stderr, "Writing some characters...");
+    rw = write(f, "some characters", 15);
+    if(rw == 15)
+      fprintf(stderr, "Done.\n");
+    else
+    {
+      fprintf(stderr, "Failed.\n");
+      return(1);
+    }
+
+    fprintf(stderr, "Waiting for \"second\" to start...");
+    while(-1 == (ff = open("flag.file",
+			   O_RDONLY,
+			   S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH)))
+      {
+	fprintf(stderr, ".");
+	sleep(1);
+      }
+    rw = read(ff, buf, 16);
+    close(ff);
+    fprintf(stderr, "Started.");
+
+    if(rw > 0)
+    {
+      buf[rw] = 0;
+      fprintf(stderr, " PID=%s\n", buf);
+    }
+    else
+      fprintf(stderr, "\n");
+
+    fprintf(stderr, "Removing the flag file...");
+    remove("flag.file");
+    fprintf(stderr, "Done.\n");
+
+    fprintf(stderr, "Holding file open (exclusively) for 10 seconds...");
+    hang_out(10);
+    fprintf(stderr, "...Done.\n");
+
+    fprintf(stderr, "Closing the file...");
+    close(f);
+    fprintf(stderr, "Done.\n");
+
+    fprintf(stderr, "Waiting a second to insure that we are into next operation...");
+    sleep(1);
+    fprintf(stderr, "Done.\n");
+
+#ifdef IN_BSD_LAND
+    fprintf(stderr, "Opening file again with shared lock...");
+    if(-1 == (f = open("delete.me",
+		       O_CREAT | O_WRONLY | O_APPEND | O_SHLOCK,
+		       S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH)))
+      {
+	fprintf(stderr, "Failed.\n");
+	return(1);
+      }
+    fprintf(stderr, "Done.\n");
+#else
+    fprintf(stderr, "Opening file again...");
+    if(-1 == (f = open("delete.me",
+		       O_CREAT | O_WRONLY | O_APPEND,
+		       S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH)))
+      {
+	fprintf(stderr, "Failed.\n");
+	return(1);
+      }
+    fprintf(stderr, "Done.\n");
+
+    fprintf(stderr, "Setting a shared lock on the file...");
+    if(-1 == flock(f, LOCK_SH))
+      {
+	fprintf(stderr, "Failed.\n");
+	return(1);
+      }
+    fprintf(stderr, "Done.\n");
+#endif
+
+    fprintf(stderr, "Closing the file...");
+    close(f);
+    fprintf(stderr, "Done.\n");
+
+  }
+
+
+
+
+  /* ======================================================================= */
+  if(0 == strcmp(argv[1], "second"))
+  {
+
+    fprintf(stderr, "Signaling that I have started...");
+    if(-1 == (ff = open("flag.file",
+			O_CREAT | O_TRUNC | O_WRONLY,
+			S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH)))
+    {
+      fprintf(stderr, "Failed.");
+      return(1);
+    }
+    sprintf(buf, "%d", getpid());
+    /*fprintf(stderr, "[%s]", buf);*/
+    rw = write(ff, buf, strlen(buf));
+    close(ff);
+    if(rw == strlen(buf))
+      fprintf(stderr, "Done.\n");
+    else
+      fprintf(stderr, "Completed, with errors.\n");
+
+
+
+#ifdef IN_BSD_LAND
+    fprintf(stderr, "Opening file with shared lock...");
+    if(-1 == (f = open("delete.me",
+		       O_RDWR | O_SHLOCK,
+		       S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH)))
+    {
+      fprintf(stderr, "Failed.\n");
+      return(1);
+    }
+    fprintf(stderr, "Done.\n");
+
+#else
+    fprintf(stderr, "Opening file...");
+    if(-1 == (f = open("delete.me",
+		       O_RDWR,
+		       S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH)))
+    {
+      fprintf(stderr, "Failed.\n");
+      return(1);
+    }
+    fprintf(stderr, "Done.\n");
+
+    fprintf(stderr, "Setting a shared lock on the file...");
+    if(-1 == flock(f, LOCK_SH))
+      {
+	fprintf(stderr, "Failed.\n");
+	return(1);
+      }
+    fprintf(stderr, "Done.\n");
+#endif
+
+    fprintf(stderr, "Reading some characters...");
+    rw = read(f, &buf, 15);
+    if(rw == 15)
+      fprintf(stderr, "Done.\n");
+    else
+      {
+	fprintf(stderr, "Failed.\n");
+	return(1);
+      }
+
+ 
+    fprintf(stderr, "Upgrading file lock to exclusive...");
+    if(-1 == flock(f, LOCK_EX))
+      {
+	fprintf(stderr, "Failed.\n");
+	return(1);
+      }
+    fprintf(stderr, "Done.\n");
+
+    fprintf(stderr, "Writing a character...");
+    rw = write(f, "\n", 1);
+    if(rw == 1)
+      fprintf(stderr, "Done.\n");
+    else
+      {
+	fprintf(stderr, "Failed.\n");
+	return(1);
+      }
+
+    fprintf(stderr, "Holding file open with exclusive lock for 10 seconds...");
+    hang_out(10);
+    fprintf(stderr, "...Done.\n");
+
+
+
+    fprintf(stderr, "Downgrading file lock to shared...");
+    if(-1 == flock(f, LOCK_SH))
+      {
+	fprintf(stderr, "Failed.\n");
+	return(1);
+      }
+    fprintf(stderr, "Done.\n");
+
+
+   fprintf(stderr, "Holding file open with shared lock for 10 seconds...");
+    hang_out(10);
+    fprintf(stderr, "...Done.\n");
+
+
+    fprintf(stderr, "Closing the file...");
+    close(f);
+    fprintf(stderr, "Done.\n");
+  }
+
+  
+  return(0);
+}
diff -Naur '--exclude=.*' make/flock.orig/src/Makefile make/flock/src/Makefile
--- make/flock.orig/src/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ make/flock/src/Makefile	2012-05-05 22:00:45.000000000 +0200
@@ -0,0 +1,7 @@
+CC=
+CFLAGS=
+
+all: flock
+
+flock: flock.c
+	${CC} ${CFLAGS} -o flock flock.c
Code:
root@fritz:/var/media/ftp/uStor01/archiv# ./flock -h
flock - An instructive file locking tool.
        Open two windows, and in the first window run "flock first", then in
        the second window run "flock second". The first will hold open the
        file with a shared lock for 10 seconds. The second will open the file
        with a shared lock then attempt to convert the lock to exclusive. The
        second will block waiting for the first to release the lock (when it
        closes the file). Remember: flock blocks!
 
Hier ein Paket (Patch) für flock mit Freetz:

Super, vielen Dank. Ich habe den Patch mit

Code:
patch -p0 <flock.patch

angewendet. Wie überrede ich jetzt das Build-System, damit flock mitgebaut wird? Ich kann im Menu keinen passenden Eintrag finden.

Code:
root@fritz:/var/media/ftp/uStor01/archiv# ./flock -h
flock - An instructive file locking tool.
        Open two windows, and in the first window run "flock first", then in
        the second window run "flock second". The first will hold open the
        file with a shared lock for 10 seconds. The second will open the file
        with a shared lock then attempt to convert the lock to exclusive. The
        second will block waiting for the first to release the lock (when it
        closes the file). Remember: flock blocks!

Die Beschreibung verstehe ich nicht: Woher kommen die 10 Sekunden? Und sonst wird flock unter Linux doch z.B. mit

Code:
flock lockfile -c command

aufgerufen?!
 
Wie überrede ich jetzt das Build-System, damit flock mitgebaut wird? Ich kann im Menu keinen passenden Eintrag finden.
Du kannst das binary mit "make flock-precompiled" kompilieren. Wenn Du flock im Freetz-Image haben willst bzw. einen Eintrag im Menu haben willst, dann musst Du einen Eintrag in die Datei "make/Config.in" machen.

Die Beschreibung verstehe ich nicht: Woher kommen die 10 Sekunden? Und sonst wird flock unter Linux doch z.B. mit
Code:
flock lockfile -c command
aufgerufen?!
Hast Du einen Link zum Quellcode für "flock unter Linux"?
 
Du kannst das binary mit "make flock-precompiled" kompilieren. Wenn Du flock im Freetz-Image haben willst bzw. einen Eintrag im Menu haben willst, dann musst Du einen Eintrag in die Datei "make/Config.in" machen.

Ok, nochmal danke :).

Hast Du einen Link zum Quellcode für "flock unter Linux"?

flock steckt bei Ubuntu im Paket util-linux:

flock.c:

Code:
/* ----------------------------------------------------------------------- *
 *
 *   Copyright 2003-2005 H. Peter Anvin - All Rights Reserved
 *
 *   Permission is hereby granted, free of charge, to any person
 *   obtaining a copy of this software and associated documentation
 *   files (the "Software"), to deal in the Software without
 *   restriction, including without limitation the rights to use,
 *   copy, modify, merge, publish, distribute, sublicense, and/or
 *   sell copies of the Software, and to permit persons to whom
 *   the Software is furnished to do so, subject to the following
 *   conditions:
 *
 *   The above copyright notice and this permission notice shall
 *   be included in all copies or substantial portions of the Software.
 *
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 *   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 *   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 *   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 *   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 *   OTHER DEALINGS IN THE SOFTWARE.
 *
 * ----------------------------------------------------------------------- */

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include <signal.h>
#include <ctype.h>
#include <string.h>
#include <paths.h>
#include <sysexits.h>
#include <sys/types.h>
#include <sys/file.h>
#include <sys/time.h>
#include <sys/wait.h>

#include "nls.h"

static const struct option long_options[] = {
  { "shared",       0, NULL, 's' },
  { "exclusive",    0, NULL, 'x' },
  { "unlock",       0, NULL, 'u' },
  { "nonblocking",  0, NULL, 'n' },
  { "nb",           0, NULL, 'n' },
  { "timeout",      1, NULL, 'w' },
  { "wait",         1, NULL, 'w' },
  { "close",        0, NULL, 'o' },
  { "help",         0, NULL, 'h' },
  { "version",      0, NULL, 'V' },
  { 0, 0, 0, 0 }
};

const char *program;

static void usage(int ex)
{
  fputs("flock (" PACKAGE_STRING ")\n", stderr);
  fprintf(stderr,
	_("Usage: %1$s [-sxun][-w #] fd#\n"
	  "       %1$s [-sxon][-w #] file [-c] command...\n"
	  "       %1$s [-sxon][-w #] directory [-c] command...\n"
	  "  -s  --shared     Get a shared lock\n"
	  "  -x  --exclusive  Get an exclusive lock\n"
	  "  -u  --unlock     Remove a lock\n"
	  "  -n  --nonblock   Fail rather than wait\n"
	  "  -w  --timeout    Wait for a limited amount of time\n"
	  "  -o  --close      Close file descriptor before running command\n"
	  "  -c  --command    Run a single command string through the shell\n"
	  "  -h  --help       Display this text\n"
	  "  -V  --version    Display version\n"),
	  program);
  exit(ex);
}


static sig_atomic_t timeout_expired = 0;

static void timeout_handler(int sig)
{
  (void)sig;

  timeout_expired = 1;
}


static char * strtotimeval(const char *str, struct timeval *tv)
{
  char *s;
  long fs;			/* Fractional seconds */
  int i;

  tv->tv_sec = strtol(str, &s, 10);
  fs = 0;

  if ( *s == '.' ) {
    s++;

    for ( i = 0 ; i < 6 ; i++ ) {
      if ( !isdigit(*s) )
	break;

      fs *= 10;
      fs += *s++ - '0';
    }

    for ( ; i < 6; i++ )
      fs *= 10;

    while ( isdigit(*s) )
      s++;
  }

  tv->tv_usec = fs;
  return s;
}

int main(int argc, char *argv[])
{
  struct itimerval timeout, old_timer;
  int have_timeout = 0;
  int type = LOCK_EX;
  int block = 0;
  int fd = -1;
  int opt, ix;
  int do_close = 0;
  int err;
  int status;
  char *eon;
  char **cmd_argv = NULL, *sh_c_argv[4];
  const char *filename = NULL;
  struct sigaction sa, old_sa;

  setlocale(LC_ALL, "");
  bindtextdomain(PACKAGE, LOCALEDIR);
  textdomain(PACKAGE);

  program = argv[0];

  if ( argc < 2 )
    usage(EX_USAGE);

  memset(&timeout, 0, sizeof timeout);

  optopt = 0;
  while ( (opt = getopt_long(argc, argv, "+sexnouw:hV?", long_options, &ix)) != EOF ) {
    switch(opt) {
    case 's':
      type = LOCK_SH;
      break;
    case 'e':
    case 'x':
      type = LOCK_EX;
      break;
    case 'u':
      type = LOCK_UN;
      break;
    case 'o':
      do_close = 1;
      break;
    case 'n':
      block = LOCK_NB;
      break;
    case 'w':
      have_timeout = 1;
      eon = strtotimeval(optarg, &timeout.it_value);
      if ( *eon )
	usage(EX_USAGE);
      break;
    case 'V':
      printf("flock (%s)\n", PACKAGE_STRING);
      exit(0);
    default:
      /* optopt will be set if this was an unrecognized option, i.e. *not* 'h' or '?' */
      usage(optopt ? EX_USAGE : 0);
      break;
    }
  }

  if ( argc > optind+1 ) {
    /* Run command */

    if ( !strcmp(argv[optind+1], "-c") ||
	 !strcmp(argv[optind+1], "--command") ) {

      if ( argc != optind+3 ) {
	fprintf(stderr, _("%s: %s requires exactly one command argument\n"),
		program, argv[optind+1]);
	exit(EX_USAGE);
      }

      cmd_argv = sh_c_argv;

      cmd_argv[0] = getenv("SHELL");
      if ( !cmd_argv[0] || !*cmd_argv[0] )
	cmd_argv[0] = _PATH_BSHELL;

      cmd_argv[1] = "-c";
      cmd_argv[2] = argv[optind+2];
      cmd_argv[3] = 0;
    } else {
      cmd_argv = &argv[optind+1];
    }

    filename = argv[optind];
    fd = open(filename, O_RDONLY|O_NOCTTY|O_CREAT, 0666);
    /* Linux doesn't like O_CREAT on a directory, even though it should be a
       no-op */
    if (fd < 0 && errno == EISDIR)
        fd = open(filename, O_RDONLY|O_NOCTTY);

    if ( fd < 0 ) {
      err = errno;
      fprintf(stderr, _("%s: cannot open lock file %s: %s\n"),
	      program, argv[optind], strerror(err));
      exit((err == ENOMEM||err == EMFILE||err == ENFILE) ? EX_OSERR :
	   (err == EROFS||err == ENOSPC) ? EX_CANTCREAT :
	   EX_NOINPUT);
    }

  } else if (optind < argc) {
    /* Use provided file descriptor */

    fd = (int)strtol(argv[optind], &eon, 10);
    if ( *eon || !argv[optind] ) {
      fprintf(stderr, _("%s: bad number: %s\n"), program, argv[optind]);
      exit(EX_USAGE);
    }

  } else {
    /* Bad options */

    fprintf(stderr, _("%s: requires file descriptor, file or directory\n"),
		program);
    exit(EX_USAGE);
  }


  if ( have_timeout ) {
    if ( timeout.it_value.tv_sec == 0 &&
	 timeout.it_value.tv_usec == 0 ) {
      /* -w 0 is equivalent to -n; this has to be special-cased
	 because setting an itimer to zero means disabled! */

      have_timeout = 0;
      block = LOCK_NB;
    } else {
      memset(&sa, 0, sizeof sa);

      sa.sa_handler = timeout_handler;
      sa.sa_flags   = SA_RESETHAND;
      sigaction(SIGALRM, &sa, &old_sa);

      setitimer(ITIMER_REAL, &timeout, &old_timer);
    }
  }

  while ( flock(fd, type|block) ) {
    switch( (err = errno) ) {
    case EWOULDBLOCK:		/* -n option set and failed to lock */
      exit(1);
    case EINTR:			/* Signal received */
      if ( timeout_expired )
	exit(1);		/* -w option set and failed to lock */
      continue;			/* otherwise try again */
    default:			/* Other errors */
      if ( filename )
	fprintf(stderr, "%s: %s: %s\n", program, filename, strerror(err));
      else
	fprintf(stderr, "%s: %d: %s\n", program, fd, strerror(err));
      exit((err == ENOLCK||err == ENOMEM) ? EX_OSERR : EX_DATAERR);
    }
  }

  if ( have_timeout ) {
    setitimer(ITIMER_REAL, &old_timer, NULL); /* Cancel itimer */
    sigaction(SIGALRM, &old_sa, NULL); /* Cancel signal handler */
  }

  status = 0;

  if ( cmd_argv ) {
    pid_t w, f;

    /* Clear any inherited settings */
    signal(SIGCHLD, SIG_DFL);
    f = fork();

    if ( f < 0 ) {
      err = errno;
      fprintf(stderr, _("%s: fork failed: %s\n"), program, strerror(err));
      exit(EX_OSERR);
    } else if ( f == 0 ) {
      if ( do_close )
	close(fd);
      execvp(cmd_argv[0], cmd_argv);
      err = errno;
      /* execvp() failed */
      fprintf(stderr, "%s: %s: %s\n", program, cmd_argv[0], strerror(err));
      _exit((err == ENOMEM) ? EX_OSERR: EX_UNAVAILABLE);
    } else {
      do {
	w = waitpid(f, &status, 0);
	if (w == -1 && errno != EINTR)
	  break;
      } while ( w != f );

      if (w == -1) {
	err = errno;
	status = EXIT_FAILURE;
	fprintf(stderr, "%s: waitpid failed: %s\n", program, strerror(err));
      } else if ( WIFEXITED(status) )
	status = WEXITSTATUS(status);
      else if ( WIFSIGNALED(status) )
	status = WTERMSIG(status) + 128;
      else
	status = EX_OSERR;	/* WTF? */
    }
  }

  return status;
}

und nls.h:
Code:
#ifndef UTIL_LINUX_NLS_H
#define UTIL_LINUX_NLS_H

int main(int argc, char *argv[]);

#ifndef LOCALEDIR
#define LOCALEDIR "/usr/share/locale"
#endif

#ifdef HAVE_LOCALE_H
# include <locale.h>
#else
# undef setlocale
# define setlocale(Category, Locale) /* empty */
#endif

#ifdef ENABLE_NLS
# include <libintl.h>
# define _(Text) gettext (Text)
# ifdef gettext_noop
#  define N_(String) gettext_noop (String)
# else
#  define N_(String) (String)
# endif
#else
# undef bindtextdomain
# define bindtextdomain(Domain, Directory) /* empty */
# undef textdomain
# define textdomain(Domain) /* empty */
# define _(Text) (Text)
# define N_(Text) (Text)
#endif

#ifdef HAVE_LANGINFO_H
# include <langinfo.h>
#else

typedef int nl_item;
extern char *langinfo_fallback(nl_item item);

# define nl_langinfo	langinfo_fallback

enum {
	CODESET = 1,
	RADIXCHAR,
	THOUSEP,
	D_T_FMT,
	D_FMT,
	T_FMT,
	T_FMT_AMPM,
	AM_STR,
	PM_STR,

	DAY_1,
	DAY_2,
	DAY_3,
	DAY_4,
	DAY_5,
	DAY_6,
	DAY_7,

	ABDAY_1,
	ABDAY_2,
	ABDAY_3,
	ABDAY_4,
	ABDAY_5,
	ABDAY_6,
	ABDAY_7,

	MON_1,
	MON_2,
	MON_3,
	MON_4,
	MON_5,
	MON_6,
	MON_7,
	MON_8,
	MON_9,
	MON_10,
	MON_11,
	MON_12,

	ABMON_1,
	ABMON_2,
	ABMON_3,
	ABMON_4,
	ABMON_5,
	ABMON_6,
	ABMON_7,
	ABMON_8,
	ABMON_9,
	ABMON_10,
	ABMON_11,
	ABMON_12,

	ERA_D_FMT,
	ERA_D_T_FMT,
	ERA_T_FMT,
	ALT_DIGITS,
	CRNCYSTR,
	YESEXPR,
	NOEXPR
};

#endif /* !HAVE_LANGINFO_H */

#endif /* UTIL_LINUX_NLS_H */

Wenn man das Macro PACKAGE_STRING aus flock.c rausschmeist, kompiliert es für die FB.

Wo hast Du Dein flock her?
 
Holen Sie sich 3CX - völlig kostenlos!
Verbinden Sie Ihr Team und Ihre Kunden Telefonie Livechat Videokonferenzen

Gehostet oder selbst-verwaltet. Für bis zu 10 Nutzer dauerhaft kostenlos. Keine Kreditkartendetails erforderlich. Ohne Risiko testen.

3CX
Für diese E-Mail-Adresse besteht bereits ein 3CX-Konto. Sie werden zum Kundenportal weitergeleitet, wo Sie sich anmelden oder Ihr Passwort zurücksetzen können, falls Sie dieses vergessen haben.