summaryrefslogtreecommitdiffstats
path: root/sys-utils
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:26:58 +0100
committerKarel Zak2006-12-07 00:26:58 +0100
commitbaf39af15b1fe8570e6430788ec7cd4959fbc5d9 (patch)
tree296fc44adb3751a15c4cf3038af8c308358e4004 /sys-utils
parentImported from util-linux-2.13-pre1 tarball. (diff)
downloadkernel-qcow2-util-linux-baf39af15b1fe8570e6430788ec7cd4959fbc5d9.tar.gz
kernel-qcow2-util-linux-baf39af15b1fe8570e6430788ec7cd4959fbc5d9.tar.xz
kernel-qcow2-util-linux-baf39af15b1fe8570e6430788ec7cd4959fbc5d9.zip
Imported from util-linux-2.13-pre2 tarball.
Diffstat (limited to 'sys-utils')
-rw-r--r--sys-utils/Makefile.am6
-rw-r--r--sys-utils/Makefile.in257
-rw-r--r--sys-utils/flock.1133
-rw-r--r--sys-utils/flock.c405
-rw-r--r--sys-utils/readprofile.c4
-rw-r--r--sys-utils/tunelp.c2
6 files changed, 465 insertions, 342 deletions
diff --git a/sys-utils/Makefile.am b/sys-utils/Makefile.am
index bd531ca1b..451143652 100644
--- a/sys-utils/Makefile.am
+++ b/sys-utils/Makefile.am
@@ -2,11 +2,11 @@ include $(top_srcdir)/config/include-Makefile.am
bin_PROGRAMS = dmesg
-usrbin_PROGRAMS = cytune flock ipcrm ipcs renice setsid
+usrbinexec_PROGRAMS = cytune flock ipcrm ipcs renice setsid
sbin_PROGRAMS = ctrlaltdel
-usrsbin_PROGRAMS = readprofile tunelp
+usrsbinexec_PROGRAMS = readprofile tunelp
man_MANS = flock.1 readprofile.1 \
ctrlaltdel.8 cytune.8 dmesg.8 ipcrm.8 ipcs.8 renice.8 \
@@ -19,7 +19,7 @@ if BUILD_RDEV
if INTEL
-usrsbin_PROGRAMS += rdev
+usrsbinexec_PROGRAMS += rdev
man_MANS += rdev.8 ramsize.8 rootflags.8 vidmode.8
install-exec-hook:
diff --git a/sys-utils/Makefile.in b/sys-utils/Makefile.in
index 44da35210..e6a8f3f9e 100644
--- a/sys-utils/Makefile.in
+++ b/sys-utils/Makefile.in
@@ -39,10 +39,10 @@ host_triplet = @host@
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(top_srcdir)/config/include-Makefile.am
bin_PROGRAMS = dmesg$(EXEEXT)
-usrbin_PROGRAMS = cytune$(EXEEXT) flock$(EXEEXT) ipcrm$(EXEEXT) \
+usrbinexec_PROGRAMS = cytune$(EXEEXT) flock$(EXEEXT) ipcrm$(EXEEXT) \
ipcs$(EXEEXT) renice$(EXEEXT) setsid$(EXEEXT)
sbin_PROGRAMS = ctrlaltdel$(EXEEXT)
-usrsbin_PROGRAMS = readprofile$(EXEEXT) tunelp$(EXEEXT) \
+usrsbinexec_PROGRAMS = readprofile$(EXEEXT) tunelp$(EXEEXT) \
$(am__EXEEXT_1)
@BUILD_RDEV_TRUE@@INTEL_TRUE@am__append_1 = rdev
@BUILD_RDEV_TRUE@@INTEL_TRUE@am__append_2 = rdev.8 ramsize.8 rootflags.8 vidmode.8
@@ -59,16 +59,16 @@ mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(sbindir)" \
- "$(DESTDIR)$(usrbindir)" "$(DESTDIR)$(usrsbindir)" \
+ "$(DESTDIR)$(usrbinexecdir)" "$(DESTDIR)$(usrsbinexecdir)" \
"$(DESTDIR)$(infodir)" "$(DESTDIR)$(man1dir)" \
"$(DESTDIR)$(man8dir)"
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
-usrbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+usrbinexecPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
@BUILD_RDEV_TRUE@@INTEL_TRUE@am__EXEEXT_1 = rdev$(EXEEXT)
-usrsbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
-PROGRAMS = $(bin_PROGRAMS) $(sbin_PROGRAMS) $(usrbin_PROGRAMS) \
- $(usrsbin_PROGRAMS)
+usrsbinexecPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS) $(sbin_PROGRAMS) $(usrbinexec_PROGRAMS) \
+ $(usrsbinexec_PROGRAMS)
ctrlaltdel_SOURCES = ctrlaltdel.c
ctrlaltdel_OBJECTS = ctrlaltdel.$(OBJEXT)
ctrlaltdel_LDADD = $(LDADD)
@@ -106,12 +106,8 @@ depcomp = $(SHELL) $(top_srcdir)/config/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
- $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
- $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
-LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
- $(AM_LDFLAGS) $(LDFLAGS) -o $@
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = ctrlaltdel.c cytune.c dmesg.c flock.c ipcrm.c ipcs.c rdev.c \
readprofile.c renice.c setsid.c tunelp.c
DIST_SOURCES = ctrlaltdel.c cytune.c dmesg.c flock.c ipcrm.c ipcs.c \
@@ -140,7 +136,6 @@ ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
-AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
@@ -180,21 +175,14 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
-CXX = @CXX@
-CXXCPP = @CXXCPP@
-CXXDEPMODE = @CXXDEPMODE@
-CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
DEPDIR = @DEPDIR@
-ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
-F77 = @F77@
-FFLAGS = @FFLAGS@
GMSGFMT = @GMSGFMT@
HAVE_BLKID_FALSE = @HAVE_BLKID_FALSE@
HAVE_BLKID_TRUE = @HAVE_BLKID_TRUE@
@@ -229,8 +217,6 @@ LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
-LIBTOOL = @LIBTOOL@
-LN_S = @LN_S@
LTLIBICONV = @LTLIBICONV@
LTLIBINTL = @LTLIBINTL@
LTLIBOBJS = @LTLIBOBJS@
@@ -263,16 +249,11 @@ USE_TTY_GROUP_FALSE = @USE_TTY_GROUP_FALSE@
USE_TTY_GROUP_TRUE = @USE_TTY_GROUP_TRUE@
VERSION = @VERSION@
XGETTEXT = @XGETTEXT@
-ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
-ac_ct_CXX = @ac_ct_CXX@
-ac_ct_F77 = @ac_ct_F77@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
-am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
-am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@@ -306,9 +287,9 @@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
-usrbindir = $(prefix)/usr/bin
-usrsbindir = $(prefix)/usr/sbin
-AM_CPPFLAGS = -include ../config.h -I$(top_srcdir)/include
+usrbinexecdir = $(prefix)/usr/bin
+usrsbinexecdir = $(prefix)/usr/sbin
+AM_CPPFLAGS = -include $(top_srcdir)/config.h -I$(top_srcdir)/include
DEFAULT_INCLUDES =
man_MANS = flock.1 readprofile.1 ctrlaltdel.8 cytune.8 dmesg.8 ipcrm.8 \
ipcs.8 renice.8 setsid.8 tunelp.8 $(am__append_2)
@@ -316,7 +297,7 @@ info_TEXINFOS = ipc.texi
all: all-am
.SUFFIXES:
-.SUFFIXES: .c .dvi .html .info .lo .o .obj .pdf .ps .texi
+.SUFFIXES: .c .dvi .html .info .o .obj .pdf .ps .texi
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/config/include-Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
@@ -352,11 +333,10 @@ install-binPROGRAMS: $(bin_PROGRAMS)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
if test -f $$p \
- || test -f $$p1 \
; then \
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
- echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
- $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
else :; fi; \
done
@@ -369,38 +349,17 @@ uninstall-binPROGRAMS:
done
clean-binPROGRAMS:
- @list='$(bin_PROGRAMS)'; for p in $$list; do \
- f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
- echo " rm -f $$p $$f"; \
- rm -f $$p $$f ; \
- done
-
-installcheck-binPROGRAMS: $(bin_PROGRAMS)
- bad=0; pid=$$$$; list="$(bin_PROGRAMS)"; for p in $$list; do \
- case ' $(AM_INSTALLCHECK_STD_OPTIONS_EXEMPT) ' in \
- *" $$p "* | *" $(srcdir)/$$p "*) continue;; \
- esac; \
- f=`echo "$$p" | \
- sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
- for opt in --help --version; do \
- if "$(DESTDIR)$(bindir)/$$f" $$opt >c$${pid}_.out \
- 2>c$${pid}_.err </dev/null \
- && test -n "`cat c$${pid}_.out`" \
- && test -z "`cat c$${pid}_.err`"; then :; \
- else echo "$$f does not support $$opt" 1>&2; bad=1; fi; \
- done; \
- done; rm -f c$${pid}_.???; exit $$bad
+ -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
install-sbinPROGRAMS: $(sbin_PROGRAMS)
@$(NORMAL_INSTALL)
test -z "$(sbindir)" || $(mkdir_p) "$(DESTDIR)$(sbindir)"
@list='$(sbin_PROGRAMS)'; for p in $$list; do \
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
if test -f $$p \
- || test -f $$p1 \
; then \
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
- echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(sbinPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(sbindir)/$$f'"; \
- $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(sbinPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(sbindir)/$$f" || exit 1; \
+ echo " $(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(sbindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(sbindir)/$$f" || exit 1; \
else :; fi; \
done
@@ -413,115 +372,53 @@ uninstall-sbinPROGRAMS:
done
clean-sbinPROGRAMS:
- @list='$(sbin_PROGRAMS)'; for p in $$list; do \
- f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
- echo " rm -f $$p $$f"; \
- rm -f $$p $$f ; \
- done
-
-installcheck-sbinPROGRAMS: $(sbin_PROGRAMS)
- bad=0; pid=$$$$; list="$(sbin_PROGRAMS)"; for p in $$list; do \
- case ' $(AM_INSTALLCHECK_STD_OPTIONS_EXEMPT) ' in \
- *" $$p "* | *" $(srcdir)/$$p "*) continue;; \
- esac; \
- f=`echo "$$p" | \
- sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
- for opt in --help --version; do \
- if "$(DESTDIR)$(sbindir)/$$f" $$opt >c$${pid}_.out \
- 2>c$${pid}_.err </dev/null \
- && test -n "`cat c$${pid}_.out`" \
- && test -z "`cat c$${pid}_.err`"; then :; \
- else echo "$$f does not support $$opt" 1>&2; bad=1; fi; \
- done; \
- done; rm -f c$${pid}_.???; exit $$bad
-install-usrbinPROGRAMS: $(usrbin_PROGRAMS)
+ -test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
+install-usrbinexecPROGRAMS: $(usrbinexec_PROGRAMS)
@$(NORMAL_INSTALL)
- test -z "$(usrbindir)" || $(mkdir_p) "$(DESTDIR)$(usrbindir)"
- @list='$(usrbin_PROGRAMS)'; for p in $$list; do \
+ test -z "$(usrbinexecdir)" || $(mkdir_p) "$(DESTDIR)$(usrbinexecdir)"
+ @list='$(usrbinexec_PROGRAMS)'; for p in $$list; do \
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
if test -f $$p \
- || test -f $$p1 \
; then \
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
- echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(usrbinPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(usrbindir)/$$f'"; \
- $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(usrbinPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(usrbindir)/$$f" || exit 1; \
+ echo " $(INSTALL_PROGRAM_ENV) $(usrbinexecPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(usrbinexecdir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(usrbinexecPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(usrbinexecdir)/$$f" || exit 1; \
else :; fi; \
done
-uninstall-usrbinPROGRAMS:
+uninstall-usrbinexecPROGRAMS:
@$(NORMAL_UNINSTALL)
- @list='$(usrbin_PROGRAMS)'; for p in $$list; do \
+ @list='$(usrbinexec_PROGRAMS)'; for p in $$list; do \
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
- echo " rm -f '$(DESTDIR)$(usrbindir)/$$f'"; \
- rm -f "$(DESTDIR)$(usrbindir)/$$f"; \
- done
-
-clean-usrbinPROGRAMS:
- @list='$(usrbin_PROGRAMS)'; for p in $$list; do \
- f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
- echo " rm -f $$p $$f"; \
- rm -f $$p $$f ; \
+ echo " rm -f '$(DESTDIR)$(usrbinexecdir)/$$f'"; \
+ rm -f "$(DESTDIR)$(usrbinexecdir)/$$f"; \
done
-installcheck-usrbinPROGRAMS: $(usrbin_PROGRAMS)
- bad=0; pid=$$$$; list="$(usrbin_PROGRAMS)"; for p in $$list; do \
- case ' $(AM_INSTALLCHECK_STD_OPTIONS_EXEMPT) ' in \
- *" $$p "* | *" $(srcdir)/$$p "*) continue;; \
- esac; \
- f=`echo "$$p" | \
- sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
- for opt in --help --version; do \
- if "$(DESTDIR)$(usrbindir)/$$f" $$opt >c$${pid}_.out \
- 2>c$${pid}_.err </dev/null \
- && test -n "`cat c$${pid}_.out`" \
- && test -z "`cat c$${pid}_.err`"; then :; \
- else echo "$$f does not support $$opt" 1>&2; bad=1; fi; \
- done; \
- done; rm -f c$${pid}_.???; exit $$bad
-install-usrsbinPROGRAMS: $(usrsbin_PROGRAMS)
+clean-usrbinexecPROGRAMS:
+ -test -z "$(usrbinexec_PROGRAMS)" || rm -f $(usrbinexec_PROGRAMS)
+install-usrsbinexecPROGRAMS: $(usrsbinexec_PROGRAMS)
@$(NORMAL_INSTALL)
- test -z "$(usrsbindir)" || $(mkdir_p) "$(DESTDIR)$(usrsbindir)"
- @list='$(usrsbin_PROGRAMS)'; for p in $$list; do \
+ test -z "$(usrsbinexecdir)" || $(mkdir_p) "$(DESTDIR)$(usrsbinexecdir)"
+ @list='$(usrsbinexec_PROGRAMS)'; for p in $$list; do \
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
if test -f $$p \
- || test -f $$p1 \
; then \
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
- echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(usrsbinPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(usrsbindir)/$$f'"; \
- $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(usrsbinPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(usrsbindir)/$$f" || exit 1; \
+ echo " $(INSTALL_PROGRAM_ENV) $(usrsbinexecPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(usrsbinexecdir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(usrsbinexecPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(usrsbinexecdir)/$$f" || exit 1; \
else :; fi; \
done
-uninstall-usrsbinPROGRAMS:
+uninstall-usrsbinexecPROGRAMS:
@$(NORMAL_UNINSTALL)
- @list='$(usrsbin_PROGRAMS)'; for p in $$list; do \
+ @list='$(usrsbinexec_PROGRAMS)'; for p in $$list; do \
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
- echo " rm -f '$(DESTDIR)$(usrsbindir)/$$f'"; \
- rm -f "$(DESTDIR)$(usrsbindir)/$$f"; \
- done
-
-clean-usrsbinPROGRAMS:
- @list='$(usrsbin_PROGRAMS)'; for p in $$list; do \
- f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
- echo " rm -f $$p $$f"; \
- rm -f $$p $$f ; \
+ echo " rm -f '$(DESTDIR)$(usrsbinexecdir)/$$f'"; \
+ rm -f "$(DESTDIR)$(usrsbinexecdir)/$$f"; \
done
-installcheck-usrsbinPROGRAMS: $(usrsbin_PROGRAMS)
- bad=0; pid=$$$$; list="$(usrsbin_PROGRAMS)"; for p in $$list; do \
- case ' $(AM_INSTALLCHECK_STD_OPTIONS_EXEMPT) ' in \
- *" $$p "* | *" $(srcdir)/$$p "*) continue;; \
- esac; \
- f=`echo "$$p" | \
- sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
- for opt in --help --version; do \
- if "$(DESTDIR)$(usrsbindir)/$$f" $$opt >c$${pid}_.out \
- 2>c$${pid}_.err </dev/null \
- && test -n "`cat c$${pid}_.out`" \
- && test -z "`cat c$${pid}_.err`"; then :; \
- else echo "$$f does not support $$opt" 1>&2; bad=1; fi; \
- done; \
- done; rm -f c$${pid}_.???; exit $$bad
+clean-usrsbinexecPROGRAMS:
+ -test -z "$(usrsbinexec_PROGRAMS)" || rm -f $(usrsbinexec_PROGRAMS)
ctrlaltdel$(EXEEXT): $(ctrlaltdel_OBJECTS) $(ctrlaltdel_DEPENDENCIES)
@rm -f ctrlaltdel$(EXEEXT)
$(LINK) $(ctrlaltdel_LDFLAGS) $(ctrlaltdel_OBJECTS) $(ctrlaltdel_LDADD) $(LIBS)
@@ -588,22 +485,6 @@ distclean-compile:
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
-.c.lo:
-@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
-@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
-
-mostlyclean-libtool:
- -rm -f *.lo
-
-clean-libtool:
- -rm -rf .libs _libs
-
-distclean-libtool:
- -rm -f libtool
-
.texi.info:
restore=: && backupdir="$(am__leading_dot)am$$$$" && \
am__cwd=`pwd` && cd $(srcdir) && \
@@ -879,7 +760,7 @@ check-am: all-am
check: check-am
all-am: Makefile $(INFO_DEPS) $(PROGRAMS) $(MANS)
installdirs:
- for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(usrbindir)" "$(DESTDIR)$(usrsbindir)" "$(DESTDIR)$(infodir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man8dir)"; do \
+ for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(usrbinexecdir)" "$(DESTDIR)$(usrsbinexecdir)" "$(DESTDIR)$(infodir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man8dir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
@@ -910,15 +791,15 @@ maintainer-clean-generic:
@INTEL_FALSE@install-exec-hook:
clean: clean-am
-clean-am: clean-binPROGRAMS clean-generic clean-libtool \
- clean-sbinPROGRAMS clean-usrbinPROGRAMS clean-usrsbinPROGRAMS \
+clean-am: clean-binPROGRAMS clean-generic clean-sbinPROGRAMS \
+ clean-usrbinexecPROGRAMS clean-usrsbinexecPROGRAMS \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
- distclean-libtool distclean-tags
+ distclean-tags
dvi: dvi-am
@@ -932,10 +813,10 @@ info: info-am
info-am: $(INFO_DEPS)
-install-data-am: install-info-am install-man install-usrbinPROGRAMS \
- install-usrsbinPROGRAMS
+install-data-am: install-info-am install-man
-install-exec-am: install-binPROGRAMS install-sbinPROGRAMS
+install-exec-am: install-binPROGRAMS install-sbinPROGRAMS \
+ install-usrbinexecPROGRAMS install-usrsbinexecPROGRAMS
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) install-exec-hook
@@ -973,8 +854,7 @@ install-info-am: $(INFO_DEPS)
else : ; fi
install-man: install-man1 install-man8
-installcheck-am: installcheck-binPROGRAMS installcheck-sbinPROGRAMS \
- installcheck-usrbinPROGRAMS installcheck-usrsbinPROGRAMS
+installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
@@ -985,7 +865,7 @@ maintainer-clean-am: distclean-am maintainer-clean-aminfo \
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-aminfo mostlyclean-compile \
- mostlyclean-generic mostlyclean-libtool
+ mostlyclean-generic
pdf: pdf-am
@@ -996,31 +876,28 @@ ps: ps-am
ps-am: $(PSS)
uninstall-am: uninstall-binPROGRAMS uninstall-info-am uninstall-man \
- uninstall-sbinPROGRAMS uninstall-usrbinPROGRAMS \
- uninstall-usrsbinPROGRAMS
+ uninstall-sbinPROGRAMS uninstall-usrbinexecPROGRAMS \
+ uninstall-usrsbinexecPROGRAMS
uninstall-man: uninstall-man1 uninstall-man8
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
- clean-generic clean-libtool clean-sbinPROGRAMS \
- clean-usrbinPROGRAMS clean-usrsbinPROGRAMS ctags dist-info \
- distclean distclean-compile distclean-generic \
- distclean-libtool distclean-tags distdir dvi dvi-am html \
- html-am info info-am install install-am install-binPROGRAMS \
- install-data install-data-am install-exec install-exec-am \
- install-exec-hook install-info install-info-am install-man \
- install-man1 install-man8 install-sbinPROGRAMS install-strip \
- install-usrbinPROGRAMS install-usrsbinPROGRAMS installcheck \
- installcheck-am installcheck-binPROGRAMS \
- installcheck-sbinPROGRAMS installcheck-usrbinPROGRAMS \
- installcheck-usrsbinPROGRAMS installdirs maintainer-clean \
- maintainer-clean-aminfo maintainer-clean-generic mostlyclean \
- mostlyclean-aminfo mostlyclean-compile mostlyclean-generic \
- mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
- uninstall-am uninstall-binPROGRAMS uninstall-info-am \
- uninstall-man uninstall-man1 uninstall-man8 \
- uninstall-sbinPROGRAMS uninstall-usrbinPROGRAMS \
- uninstall-usrsbinPROGRAMS
+ clean-generic clean-sbinPROGRAMS clean-usrbinexecPROGRAMS \
+ clean-usrsbinexecPROGRAMS ctags dist-info distclean \
+ distclean-compile distclean-generic distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-binPROGRAMS install-data install-data-am install-exec \
+ install-exec-am install-exec-hook install-info install-info-am \
+ install-man install-man1 install-man8 install-sbinPROGRAMS \
+ install-strip install-usrbinexecPROGRAMS \
+ install-usrsbinexecPROGRAMS installcheck installcheck-am \
+ installdirs maintainer-clean maintainer-clean-aminfo \
+ maintainer-clean-generic mostlyclean mostlyclean-aminfo \
+ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-binPROGRAMS \
+ uninstall-info-am uninstall-man uninstall-man1 uninstall-man8 \
+ uninstall-sbinPROGRAMS uninstall-usrbinexecPROGRAMS \
+ uninstall-usrsbinexecPROGRAMS
@BUILD_RDEV_TRUE@@INTEL_TRUE@install-exec-hook:
diff --git a/sys-utils/flock.1 b/sys-utils/flock.1
index e9cdb979a..4d12be2c1 100644
--- a/sys-utils/flock.1
+++ b/sys-utils/flock.1
@@ -1,47 +1,106 @@
-.TH FLOCK "1" "November 2004" "flock (util-linux)" "User Commands"
+.\" $Id: flock.1,v 1.2 2005/07/09 21:34:44 hpa Exp $
+.\" -----------------------------------------------------------------------
+.\"
+.\" Copyright 2003 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.
+.\"
+.\" -----------------------------------------------------------------------
+.TH FLOCK "1" "17 Mar 2003" "flock utility" "H. Peter Anvin"
.SH NAME
-flock \- acquire a file lock and then execute a command with the lock held
+flock \- Manage locks from shell scripts
.SH SYNOPSIS
-.BR flock
-.RB [ \-\-shared ]
-.RB [ \-\-timeout=\fP\fIseconds\fP ]
-.I lockfile command ...
+\fBflock\fP [\fB\-sxon\fP] [\fB\-w\fP \fItimeout\fP] \fIlockfile\fP [\fB\-c\fP] \fIcommand...\fP
+.PP
+\fBflock\fP [\fB\-sxun\fP] [\fB\-w\fP \fItimeout\fP] \fIfd\fP
.SH DESCRIPTION
-.\" Add any additional description here
.PP
-Acquire a file lock using the flock(2) system call and then execute
-the given command with the lock held. Depending on the options given,
-the lock can be either exclusive or shared, and the behavior in the
-event of lock contention can be specified as either waiting
-indefinitely for the lock to become available (the default), or
-failing if the lock does not become available after a specific time,
-which can be specified as zero to make the command not wait at all.
+This utility manages
+.BR flock (2)
+locks from within shell scripts or the command line.
.PP
-.TP
-\fB\-\-shared\fR
-Acquire a shared lock. Acquiring a shared lock does
-not stop others from acquiring a shared lock, but it will stop others
-from acquiring an exclusive lock. Conversely, acquiring an exclusive
-lock (the default) stops both exclusive and shared attempts to acquire
-the lock. Typically, a shared lock is used if a command is just going
-to read the locked data, and an exclusive lock is used if the command
-might write to it.
-.TP
-\fB\-\-timeout=n\fR
-Abort if the lock cannot be acquired before \fIn\fR seconds.
-For a completely non-blocking attempt to acquire a lock, specify
-\fB\-\-timeout=0\fR.
-The timer applies only to the attempt to acquire the lock. As soon
-as the lock is acquired, the timeout is cancelled. The command to
-be run is not subject to the timeout.
+The first form wraps the lock around the executing a command, in a manner similar to
+.BR su (1)
+or
+.BR newgrp (1).
+It locks a specified file, which is created (assuming appropriate
+permissions), if it does not already exist.
.PP
-.SH "EXAMPLES (invoking some imaginary programs)"
-.hl
+The second form is conveninent inside shell scripts, and is usually
+used the following manner:
.PP
-flock /etc/passwd read-and-write-to-passwd
+\fC(
+.br
+ flock -s 200
+.br
+ # ... commands executed under lock ...
+.br
+) 200>/var/lock/mylockfile\fP
.PP
-flock \-\-shared /etc/passwd just-read-something-from-passwd
+The mode used to open the file doesn't matter to \fBflock\fP; using
+\fC>\fP or \fP>>\fP allows the lockfile to be created if it does not
+already exist, however, write permission is required; using \fC<\fP
+requires that the file already exists but only read permission is
+required.
.PP
-flock \-\-timeout=0 /sys /usr/local/bin/update-hotplug /sys
+By default, if the lock cannot be immediately acquired, \fBflock\fP
+waits until the lock is available.
+.SH OPTIONS
+.TP
+\fB\-s\fP, \fB\-\-shared\fP
+Obtain a shared lock, sometimes called a read lock.
+.TP
+\fB\-x\fP, \fB\-\-exclusive\fP
+Obtain an exclusive lock, sometimes called a write lock. This is the
+default.
+.TP
+\fB\-u\fP, \fB\-\-unlock\fP
+Drop a lock. This is usually not required, since a lock is
+automatically dropped when the file is closed. However, it may be
+required in special cases, for example if the enclosed command group
+may have forked a background process which should not be holding the
+lock.
+.TP
+\fB\-n\fP, \fB\-\-nonblock\fP
+Fail (with an exit code of 1) rather than wait if the lock cannot be
+immediately acquired.
+.TP
+\fB\-w\fP, \fB\-\-timeout\fP \fIseconds\fP
+Fail (with an exit code of 1) if the lock cannot be acquired within
+\fIseconds\fP seconds. Decimal fractional values are allowed.
+.TP
+\fB\-o\fP, \fB\-\-close\fP
+Close the file descriptor on which the lock is held before executing
+\fIcommand\fP. This is useful if \fIcommand\fP spawns a child process
+which should not be hold ing the lock.
+.TP
+\fB\-h\fP, \fB\-\-help\fP
+Print a help message.
.SH AUTHOR
-Written by Adam J. Richter
+Written by H. Peter Anvin <hpa@zytor.com>.
+.SH COPYRIGHT
+Copyright \(co 2003\-2005 H. Peter Anvin.
+.br
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+.SH "SEE ALSO"
+.BR flock (2)
diff --git a/sys-utils/flock.c b/sys-utils/flock.c
index 27d78d43c..8ea5fce6c 100644
--- a/sys-utils/flock.c
+++ b/sys-utils/flock.c
@@ -1,116 +1,303 @@
-/*
- flock - acquires a file lock and executes a command with the lock held.
- Usage: flock [--shared | --timeout=seconds] lockfile program [args...]
-
- Written by Adam J. Richter
- Copyright (C) 2004 Yggdrasil Computing, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-#include <sys/file.h>
+/* $Id: flock.c,v 1.13 2005/07/11 05:32:56 hpa Exp $ */
+/* ----------------------------------------------------------------------- *
+ *
+ * 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 <getopt.h>
-#include <unistd.h>
-#include <stdlib.h> /* exit */
-#include <signal.h> /* kill */
-#include <stdio.h>
-#include "nls.h"
-
-static int non_blocking = 0;
-static int shared = LOCK_EX;
-static const struct option options[] = {
- {"shared", no_argument, &shared, LOCK_SH },
- {"timeout", required_argument, NULL, 't' },
- {NULL, 0, NULL, 0 },
+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 }
};
-int main(int argc, char **argv)
+const char *program;
+
+static void usage(int ex)
+{
+ fprintf(stderr,
+ "flock (%s)\n"
+ "Usage: %s [-seun][-w #] fd#\n"
+ " %s [-seon][-w #] file [-c] command...\n"
+ " -s --shared Get a shared lock\n"
+ " -e --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",
+ PACKAGE_STRING, program, 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[])
{
- int fd;
- int opt;
- int pid;
- int child_status;
- int option_index;
- int timeout = 0;
-
- setlocale(LC_ALL, "");
- bindtextdomain(PACKAGE, LOCALEDIR);
- textdomain(PACKAGE);
-
- do {
- opt = getopt_long(argc, argv, "+", options, &option_index);
- switch(opt) {
- case '?':
- fprintf (stderr,
- _("flock: unknown option, aborting.\n"));
- exit(1);
- break;
- case 't':
- timeout = atoi(optarg);
- if (timeout == 0)
- non_blocking |= LOCK_NB;
- break;
- default:
- break;
- }
- } while (opt != -1);
-
- argc -= optind;
- argv += optind;
-
- if (argc < 2) {
- fprintf(stderr,
- _("Usage flock [--shared] [--timeout=seconds] "
- "filename command {arg arg...}\n"));
- exit(2);
- }
-
- fd = open(argv[0], O_RDONLY);
- if (fd < 0) {
- perror(argv[0]);
- exit(3);
- }
-
- alarm(timeout);
- if (flock(fd, shared | non_blocking) != 0) {
- perror("flock");
- exit(4);
- }
- alarm(0);
-
- pid = fork();
- if (pid < 0) {
- perror("fork");
- exit(5);
- }
- if (pid == 0) {
- execvp(argv[1], argv+1);
- perror(argv[1]);
- exit(6);
- }
- waitpid(pid, &child_status, 0);
-
- /* flock(fd, LOCK_UN); */
- /* No need to explicitly release the flock, since we are just
- going to exit now anyhow. */
-
- /* Lame attempt to simulate child's mode of death. */
- if (WIFSIGNALED(child_status))
- kill(0, WTERMSIG(child_status));
-
- return WEXITSTATUS(child_status);
+ 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;
+
+ 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_CREAT, 0666);
+
+ 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 {
+ /* 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);
+ }
+
+ }
+
+ 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_ONESHOT;
+ 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;
+
+ f = fork();
+
+ if ( f < 0 ) {
+ err = errno;
+ fprintf(stderr, "%s: fork: %s\n", program, strerror(err));
+ exit(EX_OSERR);
+ } else if ( f == 0 ) {
+ if ( do_close )
+ close(fd);
+ err = errno;
+ execvp(cmd_argv[0], cmd_argv);
+ /* 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);
+ } while ( w != f );
+
+ if ( WIFEXITED(status) )
+ status = WEXITSTATUS(status);
+ else if ( WIFSIGNALED(status) )
+ status = WTERMSIG(status) + 128;
+ else
+ status = EX_OSERR; /* WTF? */
+ }
+ }
+
+ return status;
}
+
diff --git a/sys-utils/readprofile.c b/sys-utils/readprofile.c
index 6e1c3fcf0..43991f2fc 100644
--- a/sys-utils/readprofile.c
+++ b/sys-utils/readprofile.c
@@ -194,8 +194,8 @@ main(int argc, char **argv) {
optVerbose++;
break;
case 'V':
- printf(_("%s version %s\n"), prgname,
- VERSION);
+ printf(_("%s (%s)\n"), prgname,
+ PACKAGE_STRING);
exit(0);
default:
usage();
diff --git a/sys-utils/tunelp.c b/sys-utils/tunelp.c
index 168a7c6a0..d98c521ef 100644
--- a/sys-utils/tunelp.c
+++ b/sys-utils/tunelp.c
@@ -81,7 +81,7 @@ print_usage(char *progname) {
static void
print_version(char *progname) {
- printf("%s %s\n", progname, VERSION);
+ printf("%s (%s)\n", progname, PACKAGE_STRING);
}
static void *