From 4ca0399df42f30910576f7324f01eeb62890ed51 Mon Sep 17 00:00:00 2001 From: inglorion Date: Wed, 11 May 2005 15:45:05 +0000 Subject: [PATCH] Initial import. --- LICENSE | 20 ++++++++++++++++++++ Makefile | 29 +++++++++++++++++++++++++++++ detach.1 | 17 +++++++++++++++++ detach.c | 16 ++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 detach.1 create mode 100644 detach.c diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d8535ed --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2005 Robbert Haarman + +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. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..eae465c --- /dev/null +++ b/Makefile @@ -0,0 +1,29 @@ +PREFIX ?= /usr/local +bindir ?= ${PREFIX}/bin +mandir ?= ${PREFIX}/share/man + +TARGETS = detach +OBJECTS = + +all : $(TARGETS) + +clean : + #-rm $(OBJECTS) + +distclean : clean + -rm $(TARGETS) + +install : install-bin install-man + +install-bin : detach + [ -d '${bindir}' ] || mkdir -p '${bindir}' + install -s detach '${bindir}' + +install-man : detach.1 + [ -d '${mandir}/man1' ] || mkdir -p '${mandir}/man1' + install -m 644 detach.1 '${mandir}/man1' + +love : + #unzip; strip; touch; finger; mount; fsck; more; yes; umount; sleep + +.PHONY : all clean distclean install install-bin install-man love diff --git a/detach.1 b/detach.1 new file mode 100644 index 0000000..cd4a1c0 --- /dev/null +++ b/detach.1 @@ -0,0 +1,17 @@ +.TH detach 1 +.SH NAME +.B detach +\- run a command after detaching from the terminal +.SH SYNOPSIS +\fBdetach\fR \fIcommand\fR [\fIargs\fR] + +Forks a new process, detaches is from the terminal, and executes +command with the specified arguments. +.SH EXAMPLE +.B detach xterm + +Start an xterm that will not be closed when the current shell exits. +.SH AUTHOR +.B detach +was written by Robbert Haarman. See http://inglorion.net/ for contact +information. diff --git a/detach.c b/detach.c new file mode 100644 index 0000000..e433374 --- /dev/null +++ b/detach.c @@ -0,0 +1,16 @@ +#include +#include + +int main(int argc, char **argv) { + int j; + + j = 1; + if(fork()) return 0; + close(0); + close(1); + close(2); + setsid(); + execvp(argv[j], &argv[j]); + + return -1; +} -- 2.11.4.GIT