diff options
author | Max | 2017-03-28 14:06:55 -0400 |
---|---|---|
committer | Max | 2017-03-28 14:06:55 -0400 |
commit | 6315750817b3159557f07d50f425996ac6548fd2 (patch) | |
tree | 08d0704901f305c372409a443531dbfe43014d4d | |
download | aur-6315750817b3159557f07d50f425996ac6548fd2.tar.gz |
initial version commit
-rw-r--r-- | .SRCINFO | 11 | ||||
-rw-r--r-- | PKGBUILD | 17 | ||||
-rw-r--r-- | launch.c | 40 |
3 files changed, 68 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..78a0f25bad89 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,11 @@ +pkgbase = launch + pkgdesc = Launch an independent process + pkgver = 1 + pkgrel = 1 + arch = any + license = GPL + source = launch.c + sha256sums = SKIP + +pkgname = launch + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..ebb191159be0 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,17 @@ +# Maintainer: Max <silverhammermba@gmail.com> +pkgname=launch +pkgver=1 +pkgrel=1 +pkgdesc="Launch an independent process from a shell" +arch=('any') +license=('GPL') +source=('launch.c') +sha256sums=('SKIP') + +build() { + make launch +} + +package () { + install -Dm755 launch ${pkgdir}/usr/bin/launch +} diff --git a/launch.c b/launch.c new file mode 100644 index 000000000000..85bb1115384a --- /dev/null +++ b/launch.c @@ -0,0 +1,40 @@ +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> + +int main(int argc, char** argv) +{ + // need a command to run + if (argc <= 1) return 1; + + // fork to disown the child + pid_t child; + if (child = fork()) + { + if (child == -1) + { + perror("fork"); + return 1; + } + + printf("%ld\n", (long)child); + return 0; + } + + // swallow the leading arg and put a NULL at the end + for (int i = 0; i < argc - 1; ++i) + argv[i] = argv[i + 1]; + argv[argc - 1] = NULL; + + // silence output + if (!freopen("/dev/null", "w", stdout)) fprintf(stdout, "Failed to silence stdout\n"); + if (!freopen("/dev/null", "w", stderr)) fprintf(stderr, "Failed to silence stderr\n"); + + // run the command + if (execvp(argv[0], argv)) + { + if (freopen("/dev/tty", "w", stderr)) perror(argv[0]); + } + + return 1; +} |