11 int main (int argc
, char *argv
[])
17 /* This is a special feature handled in the simulator. The "42"
18 should be formed from getpid () if this was a real program. */
19 err
= readlink ("/proc/42/exe", buf
, sizeof (buf
));
22 if (err
== -1 && errno
== ENOSYS
)
28 /* Don't use an abort in the following; it might cause the printf to
29 not make it all the way to output and make debugging more
32 /* We assume the program is called with no path, so we might need to
34 if (getcwd (buf2
, sizeof (buf2
)) != buf2
)
40 if (argv
[0][0] == '/')
43 if (strchr (argv
[0] + 1, '/') != NULL
)
45 printf ("%s != %s\n", argv
[0], strrchr (argv
[0] + 1, '/'));
49 if (strcmp (argv
[0], buf
) != 0)
51 printf ("%s != %s\n", buf
, argv
[0]);
55 else if (argv
[0][0] != '.')
57 if (buf2
[strlen (buf2
) - 1] != '/')
59 strcat (buf2
, argv
[0]);
60 if (strcmp (buf2
, buf
) != 0)
62 printf ("%s != %s\n", buf
, buf2
);
68 strcat (buf2
, argv
[0] + 1);
69 if (strcmp (buf
, buf2
) != 0)
71 printf ("%s != %s\n", buf
, buf2
);