fprintf(stderr,
"usage: cycript [-c]"
#ifdef CY_ATTACH
- " [-p <pid>]"
+ " [-p <pid|name>]"
#endif
" [<script> [<arg>...]]\n"
);
case 'p': {
size_t size(strlen(arg));
char *end;
+
pid = strtoul(arg, &end, 0);
if (arg + size != end) {
- fprintf(stderr, "invalid pid for -p\n");
- return 1;
+ // XXX: arg needs to be escaped in some horrendous way of doom
+ const char *command(apr_psprintf(pool, "ps axc|sed -e '/^ *[0-9]/{s/^ *\\([0-9]*\\)\\( *[^ ]*\\)\\{3\\} *-*\\([^ ]*\\)/\\3 \\1/;/^%s /{s/^[^ ]* //;q;};};d'", arg));
+
+ if (FILE *pids = popen(command, "r")) {
+ char value[32];
+ size = 0;
+
+ for (;;) {
+ size_t read(fread(value + size, 1, sizeof(value) - size, pids));
+ if (read == 0)
+ break;
+ else {
+ size += read;
+ if (size == sizeof(value)) {
+ pid = _not(pid_t);
+ goto pclose;
+ }
+ }
+ }
+
+ size:
+ if (size == 0)
+ goto pclose;
+ if (value[size - 1] == '\n') {
+ --size;
+ goto size;
+ }
+
+ value[size] = '\0';
+ size = strlen(value);
+ pid = strtoul(value, &end, 0);
+ if (value + size != end)
+ pid = _not(pid_t);
+
+ pclose:
+ _syscall(pclose(pids));
+ }
+
+ if (pid == _not(pid_t)) {
+ fprintf(stderr, "invalid pid for -p\n");
+ return 1;
+ }
}
} break;
#endif
endif
endif
-flags += -g3 -O0 -DYYDEBUG=1
-#flags += -g0 -O3
+#flags += -g3 -O0 -DYYDEBUG=1
+flags += -g0 -O3
flags += -Wall -Werror -Wno-parentheses #-Wno-unused
flags += -fPIC -fno-common
flags += -I. -I$(shell apr-1-config --includedir)
unicode identifier support (native and \u)
-object literal compilation should use numerify strings
support unions (right now 0-1 fields parsed as struct)
\\\n escapes in strings aren't handled in the console
look into what String is, and whether to bridge it
the console frontend's error handling, well, doesn't
-setup a default hook mechanism for ffi_call passthrough
some JS callbacks don't use exception pointers at all...
a newline needs to not be allowed after a unary *
finish implementing default xml namespace statement