diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2010-09-17 17:11:34 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2010-09-17 17:11:34 +0000 |
commit | 77ba1c5c22800eddd11166109147f8f4e873dae2 (patch) | |
tree | cddc3315f4931aa967647865339fe2113fd78ad4 /control/shell.c | |
parent | e0e4ed2888ebfbb0d32d2106d78ef61b006f4004 (diff) |
merged relevant changes from Pd-extended 0.42
svn path=/trunk/externals/ggee/; revision=14153
Diffstat (limited to 'control/shell.c')
-rw-r--r-- | control/shell.c | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/control/shell.c b/control/shell.c index 79d89ca..f71ddce 100644 --- a/control/shell.c +++ b/control/shell.c @@ -198,7 +198,7 @@ static void shell_send(t_shell *x, t_symbol *s,int ac, t_atom *at) static void shell_anything(t_shell *x, t_symbol *s, int ac, t_atom *at) { int i; - char* argv[20]; + char* argv[255]; t_symbol* sym; if (!strcmp(s->s_name,"send")) { @@ -230,39 +230,35 @@ static void shell_anything(t_shell *x, t_symbol *s, int ac, t_atom *at) sys_addpollfn(x->fdpipe[0],shell_read,x); if (!(x->pid = fork())) { - int status; - char* cmd = getbytes(1024); - char* tcmd = getbytes(1024); - strcpy(cmd,s->s_name); - -#if 0 + /* reassign stdout */ + dup2(x->fdpipe[1],1); + dup2(x->fdinpipe[1],0); + + /* drop privileges */ + drop_priority(); + seteuid(getuid()); /* lose setuid priveliges */ + +#ifdef __APPLE__ for (i=1;i<=ac;i++) { argv[i] = getbytes(255); atom_string(at,argv[i],255); -/* post("argument %s",argv[i]); */ at++; } argv[i] = 0; -#endif - for (i=1;i<=ac;i++) { + execvp(s->s_name,argv); +#else + char* cmd = getbytes(1024); + char* tcmd = getbytes(1024); + strcpy(cmd,s->s_name); + for (i=1;i<=ac;i++) { atom_string(at,tcmd,255); strcat(cmd," "); strcat(cmd,tcmd); at++; } - - - /* reassign stdout */ - dup2(x->fdpipe[1],1); - dup2(x->fdinpipe[1],0); - - /* drop privileges */ - drop_priority(); - seteuid(getuid()); /* lose setuid priveliges */ - - post("executing %s",cmd); + verbose(4,"executing %s",cmd); system(cmd); -// execvp(s->s_name,argv); +#endif /* __APPLE__ */ exit(0); } x->x_del = 4; |