-
Ken Thomases authored
This fixes several problems with the code: * The code had been assuming that the argument strings pointed to by the argv array are contiguous iff certain process-name-setting functions are available. This doesn't seem reliable. Instead, test if it's true and shift the strings if so. However, setproctitle() is specifically documented as a preferred alternative to the technique of overwriting the arg strings, so don't shift the strings if that's available. * Use the last path component, recognizing backslash as a path separator, for setprogname() in addition to prctl(). First, setprogname() is documented as searching for the last component itself, but it doesn't understand Windows- style paths, so we need to help it. Second, on some platforms (e.g. macOS), setprogname(), like prctl(), has a fairly small internal length limit (e.g. 32 characters). So, concentrate on the most meaningful part of the path. * Remove argv[0] from argv whether or not there are any process-name-setting functions available. This is necessary for the proper functioning of Wine, so it must be done on all platforms. This part of the logic was lost with commit 5a4576ee. * Call all available process-name-setting functions instead of treating them as mutually exclusive alternatives. This is also logic that was lost with commit 5a4576ee. Signed-off-by: Ken Thomases <ken@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
a73045d6