summaryrefslogtreecommitdiff
path: root/library/quickexec.cpp
Unidiff
Diffstat (limited to 'library/quickexec.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/quickexec.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/library/quickexec.cpp b/library/quickexec.cpp
new file mode 100644
index 0000000..f3b5089
--- a/dev/null
+++ b/library/quickexec.cpp
@@ -0,0 +1,41 @@
1#include <stdio.h>
2#include <sys/types.h>
3#include <sys/stat.h>
4#include <unistd.h>
5#include <fcntl.h>
6
7#define QUICKEXEC "/tmp/.quickexec"
8
9int quickexecv( const char *path, const char *argv[] )
10{
11 int fd = open( QUICKEXEC, O_WRONLY );
12 if ( fd == -1 ) {
13 perror( "quickexec pipe" );
14 return -1;
15 }
16 write( fd, path, strlen( path )+1 );
17 const char **s = argv;
18 while( *s ) {
19 write( fd, *s, strlen( *s )+1 );
20 ++s;
21 }
22 close(fd);
23 return 0;
24}
25
26int quickexec( const char *path, const char *, ...)
27{
28 int fd = open( QUICKEXEC, O_WRONLY );
29 if ( fd == -1 ) {
30 perror( "quickexec pipe" );
31 return -1;
32 }
33 const char** s = &path;
34 do {
35 write( fd, *s, strlen( *s )+1 );
36 } while ( *(++s) );
37
38 close( fd );
39
40 return 0;
41}