summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/spawn.cc
Commit message (Collapse)AuthorAgeFilesLines
* Remove env var translation; PATH semicolon separated.Kaz Kylheku2021-07-261-1/+2
| | | | | | | | | | | | | | | * winsup/cygwin/environ.cc (conv_envvars): Static array removed. (conv_start_chars): Likewise. (getwinenv): Function gutted to just return NULL. No environment vars require conversion. (match_first_char): Static function removed. (build_env): Removed logic for eliminating those variables that require donversion, since there are no such variables and the needed functions and arrays are gone. * winsup/cygwin/environ.cc (find_exec): Recognize semicolon as PATH separator.
* Implement sh -> cmd.exe translation hack.Kaz Kylheku2021-07-261-0/+15
| | | | | * winsup/cygwin/spawn.cc (spawnve): Rewrite /bin/sh -c cmd invocations to use cmd.exe /c cmd instead.
* Small fixes in get_cmd_exe_path.Kaz Kylheku2021-07-261-11/+13
| | | | | | | | | | * winsup/cygwin/spawn.cc (init_cmd_exe_path): Restructure code to initialize rather than assign nchars. Include backslash in cmd.exe name; then it can be omitted from the size calculation and sprintf. Do not allocate an excess byte for the string. Thanks to user forsvarir of the code review stackechange. Also reformatted to the GNU style used inside Cygwin. (init_cmd_exe_path): Remove spurious whitespace.
* More secure way of obtaining command interpreter.Kaz Kylheku2021-07-261-1/+26
| | | | | | | | | | | | | | | | | | Instead of relying on the COMSPEC environment variable, what we can do is assume that the program is called "cmd.exe", and then look for it in the directory reported by the GetSystemDirectoryA Win32 function in kernel32.dll. * winsup/cygwin/path.h (get_cmd_exe_path): New function declared. * winsup/cygwin/spawn.cc (av::setup): Use get_cmd_exe_path instead of getenv("COMSPEC"). (cmd_exe_path): New static variable. (init_cmd_exe_path): New static function. (get_cmd_exe_path): New function. * winsup/cygwin/syscalls.cc (system, getusershell, popen): Use get_cmd_exe_path instead of getenv("COMSPEC").
* Use COMSPEC env var, not hard-coded CMD.EXE path.Kaz Kylheku2021-07-261-1/+4
| | | | | | | | | | | | | | | | | | | | It is with some reluctance I make this change, due to the security implications of relying on environment variables. But we can't have a hard-coded path. * winsup/cygwin/include/paths.h (_PATH_CMDEXE): Macro removed. * winsup/cygwin/spawn.cc (av::setup): Use COMSPEC environment variable instead of hard-coded path. If missing, bail with errno set to EOPNOTSUPP. * winsup/cygwin/syscalls.cc (system): Use COMSPEC environment variable. If missing, return -1. (getusershell): Eliminate static array of shell names. If shell_index is zero, return value of COMSPEC env var, if it exists, and increment shell_index to 1. (popen): Use COMSPEC and if that is missing, set errno to EOPNOTSUPP and return NULL.
* Fix spawned process window not foregrounding.Kaz Kylheku2021-07-261-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | This patch addresses an issue whereby the window of a process created with CreateProcess fails to come to the foreground. This occurs when the calling process itself hasn't run any Windows event processing loop. A repro test case is to make a program with a main, and and call CreateProcess to spawn calc.exe or notepad.exe before doing anything else. It turns out that a dummy call to TranslateMessage makes this issue goes away. If such a call is made before CreateProcess, then the spawned process' window comes up in the foreground as expected. * winsup/cygwin/Makefile.in (DLL_IMPORTS): We need to link in user32.dll to call TranslateMessage. Condense the multiple ${shell ...} call repetition with a foreach. * winsup/cygwin/spawn.cc (child_info_spawn::worker): Do the dummy TranslateMessage call before the section of code that calls CreateProcess or CreateProcessAsUser.
* Cygnal apps use cmd.exe, not /bin/sh.Kaz Kylheku2021-07-261-1/+1
| | | | | | | | | | | | | | | | | | | * winsup/cygwin/include/paths.h (_PATH_CMDEXE): New preprocessor symbol. * winsup/cygwin/spawn.cc (av_setup): Use _PATH_CMDEXE rather than "/bin/sh". * winsup/cygwin/syscalls.cc (system): Spawn _PATH_CMDEXE with /c option rather than /bin/sh. (ETC_SHELLS): Preprocessor symbol removed. (shell_fp): Global variable removed. (getusershell): Don't open ETC_SHELLS, just march through static array of shell names. That array contains only one entry: _PATH_CMDEXE. (setusershell, endusershell): Remove references to shell_fp. (popen): Exec _PATH_CMDEXE rather than "/bin/sh", and the option is /c.
* When spawning, don't try to make invisible window.Kaz Kylheku2021-07-261-2/+0
| | | | | | | | | * winsup/cygwin/spawn.cc (child_info_spawn::worker): Do not call fhandler_console::need_invisible. It's not working properly. In an application which has no console because it was compiled -mwindows, calling this funcion causes a visible console window to appear. We don't need this in Cygnal; the Microsoft spawn functions don't pop up such windows.
* Use wShowWindow when calling CreateProcess.Kaz Kylheku2021-07-261-1/+2
| | | | | | * winsup/cygwin/spawn.cc (child_info_spawn::worker): Add STARTF_USESHOWWINDOW to dwFlags of the STARTUPINFOW structure, and set wShowWindow to SW_SHOWNORMAL.
* Cygwin: Allow executing Windows Store's "app execution aliases"Johannes Schindelin2021-03-231-0/+7
| | | | | | | | | | | | | | | | | | | | | | The Windows Store version of Python (and apparently other Windows Store applications) install a special reparse point called "app execution alias" into the user's `PATH`. These applications can be executed without any problem, but they cannot be read as if they were files. This trips up Cygwin's beautiful logic that tries to determine whether we're about to execute a Cygwin executable or not: instead of executing the application, it will fail, saying "Permission denied". Let's detect this situation (`NtOpenFile()` helpfully says that this operation is not supported on this reparse point type), and simply skip the logic: Windows Store apps are not Cygwin executables (and even if they were, it is unlikely that they would come with a compatible `cygwin1.dll` or `msys-2.0.dll`). This fixes https://github.com/msys2/MSYS2-packages/issues/1943 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
* Cygwin: pty: Transfer input only if the stdin is a pty.Takashi Yano via Cygwin-patches2021-03-091-2/+7
| | | | | - The commit 12325677f73a did not fix enough. With this patch, more transfer_input() calls are skipped if stdin is redirected or piped.
* Cygwin: console: Fix restoring console mode failure.Takashi Yano via Cygwin-patches2021-03-051-4/+10
| | | | | | | - Restoring console mode fails in the following scenario. 1) Start cygwin shell in command prompt. 2) Run 'exec chcp.com'. This patch fixes the issue.
* Cygwin: console: Fix handling of Ctrl-S in Win7.Takashi Yano via Cygwin-patches2021-02-191-14/+18
| | | | | | | - If ENABLE_LINE_INPUT is set, Ctrl-S is handled by Windows if the OS is Windows 7. This conflicts with Ctrl-S handling in cygwin console code. This patch unsets ENABLE_LINE_INPUT flag in cygwin and set it when native app is executed.
* Cygwin: pty: Reduce unecessary input transfer.Takashi Yano via Cygwin-patches2021-02-121-33/+45
| | | | | | | - Currently, input transfer is performed every time one line is read(), if the non-cygwin app is running in the background. With this patch, transfer is triggered by setpgid() rather than read() so that the unnecessary input transfer can be reduced much in that situation.
* Cygwin: pty: Allow multiple apps to enable pseudo console simultaneously.Takashi Yano via Cygwin-patches2021-01-281-14/+30
| | | | | | | - After commit bb428520, there has been the disadvantage: 7) Pseudo console cannot be activated if it is already activated for another process on same pty. This patch clears this disadvantage.
* Cygwin: pty: Make apps using console APIs be able to debug with gdb.Takashi Yano via Cygwin-patches2021-01-281-0/+2
| | | | | | | | | | - After commit bb428520, there has been the disadvantage: 2) The apps which use console API cannot be debugged with gdb. This is because pseudo console is not activated since gdb uses CreateProcess() rather than exec(). Even with this limitation, attaching gdb to native app, in which pseudo console is already activated, works. This patch clears this disadvantage.
* Cygwin: pty: Inherit typeahead data between two input pipes.Takashi Yano via Cygwin-patches2021-01-281-30/+52
| | | | | | | | | | | | | | | - PTY has a problem that the key input, which is typed during windows native app is running, disappears when it returns to shell. This is beacuse pty has two input pipes, one is for cygwin apps and the other one is for native windows apps. The key input during windows native program is running is sent to the second input pipe while cygwin shell reads input from the first input pipe. This issue had been fixed once by commit 29431fcb, however, the new implementation of pseudo console support by commit bb428520 could not inherit this feature. This patch realize transfering input data between these two pipes bidirectionally by utilizing cygwin-console-helper process. The helper process is launched prior to starting the non-cygwin app, however, exits immediately unlike previous implementation.
* Cygwin: spawn.cc: Fix typo in comment by commit 974e6d76.Takashi Yano via Cygwin-patches2021-01-191-1/+1
|
* Cygwin: pty: Prevent pty from changing code page of parent console.Takashi Yano via Cygwin-patches2021-01-181-0/+1
| | | | | | | | | - After commit 232fde0e, pty changes console code page when the first non-cygwin app is executed. If pty is started in real console device, pty changes the code page of root console. This causes very annoying result because changing code page changes the font of command prompt if console is in legacy mode. This patch avoids this by creating a new invisible console for the first pty started in console device.
* Cygwin: pty: Make close_pseudoconsole() be a static member function.Takashi Yano via Cygwin-patches2021-01-181-2/+4
| | | | | | | - The function close_pseudoconsole() should be static so that it can be safely called in spawn.cc even after the fhandler_pty_slave instance has been deleted. That is, there is a problem with the current code. This patch fixes the issue.
* Cygwin: console: Revise the code to switch xterm mode.Takashi Yano via Cygwin-patches2021-01-181-2/+33
| | | | | | | | | - If application changes the console mode, mode management introduced by commit 10d8c278 will be corrupted. For example, stdout of jansi v2.0.1 or later is piped to less, jansi resets the xterm mode flag ENABLE_VIRTUAL_TERMINA_PROCESSING when jansi is terminated. This causes garbled output in less because less needs this flag enabled. This patch fixes the issue.
* Cygwin: pty: Skip term_has_pcon_cap() if pseudo console is disabled.Takashi Yano via Cygwin-patches2020-12-141-1/+1
| | | | | - This patch skips unnecessary term_has_pcon_cap() call if pseudo console is disabled.
* cygwin: use CREATE_DEFAULT_ERROR_MODE in spawnJeremy Drake via Cygwin-patches2020-12-101-0/+7
| | | | | This allows native processes to get Windows-default error handling behavior (such as invoking the registered JIT debugger).
* Cygwin: pty: Disable pseudo console if TERM does not have CSI6n.Takashi Yano via Cygwin-patches2020-08-311-7/+11
| | | | | | | | | | | | | | | | | | | - Pseudo console internally sends escape sequence CSI6n (query cursor position) on startup of non-cygwin apps. If the terminal does not support CSI6n, CreateProcess() hangs waiting for response. To prevent hang, this patch disables pseudo console if the terminal does not have CSI6n. This is checked on the first execution of non-cygwin app using the following steps. 1) Check if the terminal support ANSI escape sequences by looking into terminfo database. If terminfo has cursor_home (ESC [H), the terminal is supposed to support ANSI escape sequences. 2) If the terminal supports ANSI escape sequneces, send CSI6n for a test and wait for a responce for 40ms. 3) If there is a responce within 40ms, CSI6n is supposed to be supported. Also set-title capability is checked, and removes escape sequence for setting window title if the terminal does not have the set- title capability.
* Cygwin: drop PROC_DETACHED_CHILD flagCorinna Vinschen2020-08-281-3/+2
| | | | | | | | | | | | pinfo::remember with the detach parameter set to true is the only way to call proc_subproc with PROC_DETACHED_CHILD. This call is exclusively used in spawn to set up a pinfo for a detached child, and that pinfo goes out of scope right afterwards without any further action. Drop the flag and drop the detach parameter from pinfo::remember. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: fix up proc_subproc flags and matching pinfo methodsCorinna Vinschen2020-08-281-1/+1
| | | | | | | | | | | | | | | | After patch 23a779bf3d7c2afc9eab88f6b8727c1db5544547 "Cygwin: pinfo: stop remember doing reattach", PROC_ADDCHILD actually just sets up a new child, mirroring PROC_DETACHED_CHILD. The actual attaching of the child is performed by action PROC_REATTACH_CHILD or pinfo::reattach respectively. To better reflect what's going on, rename PROC_REATTACH_CHILD to PROC_ATTACH_CHILD and rename pinfo::reattach to pinfo::attach. For better readability change PROC_ADDCHILD to PROC_ADD_CHILD. Fix comments accordingly. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: pty: Implement new pseudo console support.Takashi Yano2020-08-221-53/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - In this implementation, pseudo console is created for each native console app. Advantages and disadvantages of this implementation over the previous implementation are as follows. Advantages: 1) No performance degradation in pty output for cygwin process. https://cygwin.com/pipermail/cygwin/2020-February/243858.html 2) Free from the problem caused by difference of behaviour of control sequences between real terminal and pseudo console. https://cygwin.com/pipermail/cygwin/2019-December/243281.html https://cygwin.com/pipermail/cygwin/2020-February/243855.html 3) Free from the problem in cgdb and emacs gud. https://cygwin.com/pipermail/cygwin/2020-January/243601.html https://cygwin.com/pipermail/cygwin/2020-March/244146.html 4) Redrawing screen on executing native console apps is not necessary. 5) cygwin-console-helper is not necessary for the pseudo console support. 6) The codes for pseudo console support are much simpler than that of the previous one. Disadvantages: 1) The cygwin program which calls console API directly does not work. 2) The apps which use console API cannot be debugged with gdb. This is because pseudo console is not activated since gdb uses CreateProcess() rather than exec(). Even with this limitation, attaching gdb to native apps, in which pseudo console is already activated, works. 3) Typeahead key inputs are discarded while native console app is executed. Simirally, typeahead key inputs while cygwin app is executed are not inherited to native console app. 4) Code page cannot be changed by chcp.com. Acctually, chcp works itself and changes code page of its own pseudo console. However, since pseudo console is recreated for another process, it cannot inherit the code page. 5) system_printf() does not work after stderr is closed. (Same with cygwin 3.0.7) 6) Startup time of native console apps is about 3 times slower than previous implemenation. 7) Pseudo console cannot be activated if it is already activated for another process on same pty.
* Cygwin: pty: Change the timing of set_locale() call again.Takashi Yano via Cygwin-patches2020-08-171-0/+12
| | | | | | | | - After commit 095972ce5b1d319915501a7e381802914bed790c, charset conversion in mintty is broken if charset is set to other than UTF-8. This seems to be caused because mintty does not set locale yet at fork() call. This patch changes the timing of set_locale() call again to avoid this issue.
* Cygwin: pty: Add a workaround for issue of starting a lot of mintty.Takashi Yano2020-08-111-4/+11
| | | | | | | | | - If a lot of mintty are started in a short time from a mintty, some of them hang with empty screen, crash immediately or hang on exiting mintty. The following report seems to be related to this issue. https://cygwin.com/pipermail/cygwin/2020-August/245751.html The cause is not clear at all, but this patch seems to solve the issue.
* Cygwin: posix_spawn: add Cygwin-specific code fixing process synchronisationCorinna Vinschen2020-08-031-0/+104
| | | | | | | | | | | | | | | | | | | | | | Newlib's posix_spawn has been taken from FreeBSD. The code relies on BSD-specific behaviour of vfork, namely the fact that vfork blocks the parent until the child exits or calls execve as well as the fact that the child shares parent memory in non-COW mode. This behaviour can't be emulated by Cygwin. Cygwin's vfork is equivalent to fork. This is POSIX-compliant, but it's lacking BSD's vfork ingrained synchronization of the parent to wait for the child calling execve, or the chance to just write a variable and the parent will see the result. So this requires a Cygwin-specific solution. The core function of posix_spawn, called do_posix_spawn is now implemented twice, once using the BSD method, and once for Cygwin using Windows synchronization under the hood waiting for the child to call execve and signalling errors upstream. The Windows specifics are hidden inside Cygwin, so newlib only calls internal Cygwin functions. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: console: Add guard for set/unset xterm compatible mode.cygwin-3_1_4-releaseTakashi Yano2020-02-181-6/+2
| | | | | - Setting / unsetting xterm compatible mode may cause race issue between multiple processes. This patch adds guard for that.
* Cygwin: console: Change timing of set/unset xterm compatible mode.cygwin-3_1_3-releaseTakashi Yano2020-02-171-16/+7
| | | | | | | | | | | | | - If two cygwin programs are executed simultaneousley with pipes in cmd.exe, xterm compatible mode is accidentally disabled by the process which ends first. After that, escape sequences are not handled correctly in the other app. This is the problem 2 reported in https://cygwin.com/ml/cygwin/2020-02/msg00116.html. This patch fixes the issue. This patch also fixes the problem 3. For these issues, the timing of setting and unsetting xterm compatible mode is changed. For read, xterm compatible mode is enabled only within read() or select() functions. For write, it is enabled every time write() is called, and restored on close().
* Cygwin: pty: Fix state mismatch caused in octave gui.Takashi Yano2020-01-171-0/+9
| | | | | | - In octave gui, sometimes state mismatch between real pty state and state variable occurs. For example, this occurs when 'ls' command is executed in octave gui. This patch fixes the issue.
* Cygwin: pty: Disable FreeConsole() on close for non cygwin process.Takashi Yano2020-01-141-2/+4
| | | | | | | | | | | | - After commit e1a0775dc0545b5f9c81b09a327fc110c538b7b4, the problem reported in https://www.cygwin.com/ml/cygwin/2020-01/msg00093.html occurs. For Gnu scren and tmux, calling FreeConsole() on pty close is necessary. However, if FreeConsole() is called, cygwin setup with '-h' option does not work. Therefore, the commit e1a0775dc0545b5f9c81b09a327fc110c538b7b4 delayed closing pty. This is the cause of the problem above. Now, instead of delaying pty close, FreeConsole() is not called if the process is non cygwin processes such as cygwin setup.
* Cygwin: console: Disable xterm mode for non cygwin process only.Takashi Yano2020-01-141-1/+20
| | | | | | | - Special function keys such as arrow keys or function keys do not work in ConEmu with cygwin-connector after commit 6a06c6bc8f8492ea09aa3ae180fe94e4ac265611. This patch fixes the issue.
* Cygwin: pty: Convert CamelCase names to snake_case names.Takashi Yano2019-11-181-9/+9
|
* Cygwin: spawnvp, spawnvpe: fail if executable is not in $PATHKen Brown2019-10-181-3/+6
| | | | | | Call find_exec with the FE_NNF flag to enforce a NULL return when the executable isn't found in $PATH. Convert NULL to "". This aligns spawnvp and spawnvpe with execvp and execvpe.
* Cygwin: pty: Fix PTY so that cygwin setup shows help with -h option.Takashi Yano2019-09-261-2/+2
| | | | | | | - After commit 169d65a5774acc76ce3f3feeedcbae7405aa9b57, cygwin setup fails to show help message when -h option is specified, as reported in https://cygwin.com/ml/cygwin/2019-09/msg00248.html. This patch fixes the problem.
* Cygwin: Fix incorrect TTY for non-cygwin process.Takashi Yano2019-09-201-4/+1
| | | | | | - After commit d4045fdbef60d8e7e0d11dfe38b048ea2cb8708b, the TTY displayed by ps command is incorrect if the process is non-cygwin process. This patch fixes this issue.
* Cygwin: pty: Switch input and output pipes individually.Takashi Yano2019-09-141-25/+19
| | | | | | | | - Previously, input and output pipes were switched together between the traditional pty and the pseudo console. However, for example, if stdin is redirected to another device, it is better to leave input pipe traditional pty side even for non-cygwin program. This patch realizes such behaviour.
* Cygwin: pty: Fix the behaviour of Ctrl-C in the pseudo console mode.Takashi Yano2019-09-141-25/+17
| | | | | | | | - When the I/O pipe is switched to the pseudo console side, the behaviour of Ctrl-C was unstable. This rarely happens, however, for example, shell sometimes crashes by Ctrl-C in that situation. Furthermore, Ctrl-C was ignored if output of non-cygwin program is redirected to pipe. This patch fixes these issues.
* Cygwin: pty: Add a workaround for ^C handling.Takashi Yano2019-09-041-0/+6
| | | | | | | | - Pseudo console support introduced by commit 169d65a5774acc76ce3f3feeedcbae7405aa9b57 sometimes cause random crash or freeze by pressing ^C while cygwin and non-cygwin processes are executed simultaneously in the same pty. This patch is a workaround for this issue.
* Cygwin: pty: Fix state management for pseudo console support.Takashi Yano2019-09-041-28/+37
| | | | | | | | - Pseudo console support introduced by commit 169d65a5774acc76ce3f3feeedcbae7405aa9b57 has some bugs which cause mismatch between state variables and real pseudo console state regarding console attaching and r/w pipe switching. This patch fixes this issue by redesigning the state management.
* Cygwin: pty: add pseudo console support.Takashi Yano2019-08-291-0/+61
| | | | | | | - Support pseudo console in PTY. Pseudo console is a new feature in Windows 10 1809, which provides console APIs on virtual terminal. With this patch, native console applications can work in PTYs such as mintty, ssh, gnu screen or tmux.
* Cygwin: exec: check execute bit prior to evaluating scriptCorinna Vinschen2019-08-061-6/+6
| | | | | | | | | | | | | | | | | When the exec family of functions is called for a script-like file, the av::setup function handles the exec[vl]p case as well. The execve case for files not starting with a she-bang is handled first by returning ENOEXEC. Only after that, the file's executability is checked. This leads to the problem that ENOEXEC is returned for non-executable files as well. A calling shell interprets this as a file it should try to run as script. This is not desired for non-executable files. Fix this problem by checking the file for executability first. Only after that, follow the other potential code paths. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: pinfo: stop remember doing reattachMichael Haubenwallner2019-07-311-1/+3
| | | | | | | | | | | | | | | During fork, the child process requires the process table to be initialized for fixup_shms_after_fork, while still allowing subsequent dlls.load_after_fork to fail silently (for when the "forkable" hardlinks are not created yet). pinfo::remember not performing reattach anymore requires explicit pinfo::reattach now where appropriate. Prepares to improve "Cygwin: fork: Remember child not before success." commit f03ea8e1c57bd5cea83f6cd47fa02870bdfeb1c5, which leads to fork problems if cygserver is running: https://cygwin.com/ml/cygwin-patches/2019-q2/msg00155.html
* Cygwin: winpids: Fix getting process multiple times, take 2Corinna Vinschen2019-04-021-5/+4
| | | | | | | | | | | | | | | | | | | | | | commit d1be0a59d48222d8ea6261ee3e59de2bc3d149e4, "Cygwin: winpids: Fix getting process multiple times" fixed duplicate processes in ps -W output, but it fixed the symptom, not the cause. It also didn't fix the problem that the `ps' process itself may show up twice in its own output. This patch fixes it. The spawn worker only deleted the "winpid.PID" symlink of the current process if the child is a non-Cygwin process, under the assumption that the exec'ing process exits anyway. However, the Window in which both winpid.PID symlinks point to the same cygpid.PID area is just too long. The spawn worker now also deletes its own winpid.PID symlink if the exec'ed process is a Cygwin process. Additionally the fix from d1be0a59d48222d8ea6261ee3e59de2bc3d149e4 is now performed on the calling process, too. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: fork/exec: Allow all users PROCESS_QUERY_LIMITED_INFORMATIONCorinna Vinschen2019-03-121-12/+18
| | | | | | | | | | | Create process with standard rights, plus PROCESS_QUERY_LIMITED_INFORMATION for authenticated users. This allows to fetch basic process information and thus /proc/<PID>/stat to succeed on foreign processes. While at it, fix formatting in CreateProcess calls. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: fix child getting another pid after spawnveCorinna Vinschen2019-02-081-6/+2
| | | | | | | | | | | | | | | | | | | When calling spawnve, in contrast to execve, the parent has to create the pid for the child. With the old technique this was simply the Windows pid, but now we have to inform the child about its new pid. Add a cygpid member to class child_info_spawn. Set it in child_info_spawn::worker, just prior to calling CreateProcess rather than afterwards. Overwrite cygheap->pid in child_info_spawn::handle_spawn before calling pinfo::thisproc. Make sure pinfo::thisproc knows the pid is already set by setting the handle argument to INVALID_HANDLE_VALUE. Also set procinfo->dwProcessId to myself_initial.dwProcessId instead of to myself_initial.pid for clarity. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: spawn: create and maintain winpid symlinksCorinna Vinschen2019-02-021-5/+25
| | | | | | | | | | | | - If the execve'ed process is a non-Cygwin process, we have to create the matching winpid symlink and remove the old one ourselves. - If we spawn a child, the winpid symlink has to be maintained by the child process, otherwise it disappears if the parent process exits. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>