On 07/30/2013 07:05 PM, Max wrote:
Am 30.07.2013 um 23:32 schrieb Jonathan Wilkes <[email protected]>:
Max- Are you experiencing dropouts from the subprocess stalling, or are you
saying you're trying to avoid the possibility of dropouts. If it's the latter,
then I'm having a hard time figuring out how two Pds connected through netsend
would avoid dropouts. Also, what causes the freezes?
Cyrille has repeatedly said on this list that [pd~] is not the way to
completely detach the two instances and that it one should use two instances
instead. Never mind - I thought there was an elegant solution to launch another
instance from a patch programmatically.
m.
Attached is a patch to s_path.c that fleshes out a pd_getdirname
function which
should return the executable's path on OSX, Windows, Linux, and FreeBSD.
I don't have FreeBSD running so I didn't test that one.
Question: should this function print an error, or should it send an
empty symbol on error
and let the caller do that? I'm currently doing the latter when using
the function in
[pdinfo]-- that let's me tailor the error message to the relevant object
which should help with
user error report. (I.e., generate a "findable" error.)
Anyway if this looks good I'll go ahead and update [pdinfo] and add a
"dir" method,
or maybe a "pddir" method. (Suggestions welcome on method name.)
-Jonathan
--- src/s_path_old.c 2011-03-10 01:02:41.000000000 -0500
+++ /src/s_path.c 2013-08-02 18:51:32.333606247 -0400
@@ -698,4 +698,44 @@ void glob_startup_dialog(t_pd *dummy, t_
}
}
-
+t_symbol *pd_getdirname(void)
+{
+ char buf[MAXPDSTRING], buf2[MAXPDSTRING];
+ int len;
+#ifdef _WIN32
+ if ((len = GetModuleFileName(NULL, buf, sizeof(buf))) == 0)
+ strcpy(buf, ".");
+ else
+ buf[len] = '\0';
+ sys_unbashfilename(buf, buf);
+#elif defined(__APPLE__)
+ len = sizeof(buf);
+ _NSGetExecutablePath(buf, &len);
+ if (len != -1) buf[len] = '\0';
+#elif defined(__FreeBSD__)
+ len = (ssize_t)(readlink("/proc/curproc/file", buf, sizeof(buf)-1));
+ if (len != -1) buf[len] = '\0';
+#else
+ len = (ssize_t)(readlink("/proc/self/exe", buf, sizeof(buf)-1));
+ if (len != -1) buf[len] = '\0';
+#endif
+ if (len != -1)
+ {
+ char *lastslash;
+ lastslash = strrchr(buf, '/');
+ if (lastslash)
+ {
+ lastslash++;
+ *lastslash= '\0';
+ strncpy(buf2, buf, lastslash-buf);
+ buf2[lastslash-buf] = '\0';
+ }
+ else strcpy(buf2, ".");
+ }
+ else
+ {
+ return 0;
+ }
+ t_symbol *foo = gensym(buf2);
+ return foo;
+}
_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management ->
http://lists.puredata.info/listinfo/pd-list