Loading...
gen/FreeBSD/setprogname.c.patch /dev/null Libc-763.13
--- /dev/null
+++ Libc/Libc-763.13/gen/FreeBSD/setprogname.c.patch
@@ -0,0 +1,37 @@
+--- setprogname.c.orig	2009-11-07 14:51:38.000000000 -0800
++++ setprogname.c	2009-11-07 14:51:39.000000000 -0800
+@@ -3,6 +3,10 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/set
+ 
+ #include <stdlib.h>
+ #include <string.h>
++#include <sys/param.h>
++#include <sys/sysctl.h>
++#include <crt_externs.h>
++#define	__progname	(*_NSGetProgname())
+ 
+ #include "libc_private.h"
+ 
+@@ -10,10 +14,20 @@ void
+ setprogname(const char *progname)
+ {
+ 	const char *p;
+-
++	char buf[2*MAXCOMLEN+1];
++	int mib[2];
++	
+ 	p = strrchr(progname, '/');
+ 	if (p != NULL)
+-		__progname = p + 1;
++		__progname = (char *)(p = p + 1);
+ 	else
+-		__progname = progname;
++		__progname = (char *)(p = progname);
++
++	strlcpy(&buf[0], (char *)(p), sizeof(buf));
++
++	mib[0] = CTL_KERN;
++	mib[1] = KERN_PROCNAME;
++
++	/* ignore errors as this is not a hard error */
++	sysctl(mib, 2, NULL, NULL, &buf[0], strlen(buf));
+ }