On 12.07.2016 06:44, Ken Thomases wrote:
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.
Thanks for working on this, looks indeed like a nice improvement.
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.
Wouldn't it make sense to remove the directory component also in this case, to be consistent? By moving the code to the bottom all functions would be called in the same way.
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 5a4576ee0.
Call all available process-name-setting functions instead of treating them as mutually exclusive alternatives. This is also logic that was lost with commit 5a4576ee0.
Signed-off-by: Ken Thomases ken@codeweavers.com
dlls/kernel32/process.c | 63 +++++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 26 deletions(-)