From 89d7fe2e1af9f4afe3a6a92fed9a5a4b2ef662ae Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 19 May 2006 19:03:38 +0000 Subject: [PATCH] forgot the readlink part svn: r2990 --- src/mzscheme/dynsrc/ustart.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/mzscheme/dynsrc/ustart.c b/src/mzscheme/dynsrc/ustart.c index 4859f60c8d..4f455b3162 100644 --- a/src/mzscheme/dynsrc/ustart.c +++ b/src/mzscheme/dynsrc/ustart.c @@ -9,6 +9,7 @@ #include #include #include +#include char *config = "[Replace me with offset info ]"; @@ -239,6 +240,28 @@ int main(int argc, char **argv) /* me is now an absolute path to the binary */ + /* resolve soft links */ + while (1) { + int len, bufsize = 127; + char *buf; + buf = (char *)malloc(bufsize + 1); + len = readlink(me, buf, bufsize); + if (len < 0) { + if (errno == ENAMETOOLONG) { + /* Increase buffer size and try again: */ + bufsize *= 2; + buf = (char *)malloc(bufsize + 1); + } else + break; + } else { + /* Resolve buf relative to me: */ + buf[len] = 0; + buf = absolutize(buf, me); + me = buf; + buf = (char *)malloc(bufsize + 1); + } + } + start = as_int(config); cmd_end = as_int(config + 4); end = as_int(config + 8);