patch from Maxime Villard with some minor changes and openbsd fixes

SVN revision: 78711
This commit is contained in:
Mike Blumenkrantz 2012-10-31 15:40:53 +00:00
parent b8b8f163d7
commit 78967eac38
1 changed files with 18 additions and 19 deletions

View File

@ -6,6 +6,7 @@
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/wait.h>
#include <pwd.h> #include <pwd.h>
#include <grp.h> #include <grp.h>
#include <fnmatch.h> #include <fnmatch.h>
@ -50,7 +51,7 @@ main(int argc,
const char *act; const char *act;
#endif #endif
gid_t gid, gl[65536], egid; gid_t gid, gl[65536], egid;
int pid; int pid = 0;
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
{ {
@ -72,8 +73,9 @@ main(int argc,
test = 1; test = 1;
action = argv[2]; action = argv[2];
} }
else if ((argc == 4) && (!strcmp(argv[1], "gdb"))) else if (!strcmp(argv[1], "gdb"))
{ {
if (argc != 4) exit(1);
char *end = NULL; char *end = NULL;
action = argv[1]; action = argv[1];
@ -109,8 +111,8 @@ main(int argc,
{ {
exit(1); exit(1);
} }
fprintf(stderr, "action %s %i\n", action, argc);
if (!action) exit(1); if (!action) exit(1);
fprintf(stderr, "action %s %i\n", action, argc);
uid = getuid(); uid = getuid();
gid = getgid(); gid = getgid();
@ -152,13 +154,12 @@ main(int argc,
exit(20); exit(20);
} }
if (!(strcmp(argv[1], "gdb"))) if (!strcmp(action, "gdb"))
{ {
Eina_Prefix *pfx = NULL; Eina_Prefix *pfx = NULL;
char buffer[4096]; char buffer[4096];
char *tmp; char *tmp;
char *enlightenment_gdb; char *enlightenment_gdb;
char *batch;
int fd; int fd;
int r; int r;
@ -171,12 +172,11 @@ main(int argc,
snprintf(buffer, 4096, snprintf(buffer, 4096,
"set logging file %s\nset logging on\nbacktrace full\n", "set logging file %s\nset logging on\nbacktrace full\n",
output); output);
batch = strdup(buffer);
tmp = strdup("/tmp/e-gdb-XXXXXX"); tmp = strdup("/tmp/e-gdb-XXXXXX");
fd = mkstemp(tmp); fd = mkstemp(tmp);
if (fd < 0) exit(-1); if (fd < 0) exit(-1);
write(fd, batch, strlen(batch)); write(fd, buffer, strlen(buffer));
close(fd); close(fd);
snprintf(buffer, 4096, snprintf(buffer, 4096,
@ -192,7 +192,6 @@ main(int argc,
unlink(tmp); unlink(tmp);
free(enlightenment_gdb); free(enlightenment_gdb);
free(batch);
free(tmp); free(tmp);
exit(WEXITSTATUS(r)); exit(WEXITSTATUS(r));