Windows terminal many tabs with [process exited with code 1 (0x00000001)] - windows

When ever I run nx serve on my windows terminal, after a while I see 100's of tabs open up with [process exited with code 1 (0x00000001)] error. They take all the focus away and I am not able to use my computer till the server is up and running.
Does anyone know why I see these tabs and how to prevent them?

You're seeing these tabs likely because you've got the Windows Terminal set as the default terminal. Windows Terminal defaults to only closing the tab/pane when a client application exits "gracefully", i.e. with an exit code of 0. The vintage console however would always close the window when the last client exits, regardless of exit code.
What you're seeing here is nx serve is spawning a bunch of child processes that are all exiting with 1, not 0. With the vintage console as the default terminal, these console windows would have all disappeared instantly. Now they all stick around as tabs in the Terminal.
You can get these tabs to disappear instantly by setting "closeOnExit": "always" in your profiles.defaults in the settings.
Ultimately though, nx should probably not be exiting with error code 1, unless there's actually a reason they're returning some sort of error (without otherwise logging any error)

Related

golang: optional console on windows

I am writing a service program which is expected to run in background. On Windows it will open a console window when run. I want it to go to background directly without that console window, so I used the -ldconf "-H=windowsgui" option, which worked as expected.
However, there is a catch. The program has a command line option -help, which output command line usage in the console. If I use -H=windowsgui, the help text is NOT printed even I start it in cmd.exe prompt.
It seems that the windowsgui option is not what I want. Is there anyway that the -help still works at commant line, and the console window will not persist if the program runs normally. I do not care if there is a console window pops up, provided that it disappears shortly without user intervention. i.e. I want a way on windows which is similar to the & operator on Linux.
P.S. if provided solution uses any other tools, I want that tool to be a Windows component, not any 3rd-party program. Thanks.

Terminal/iTerm2 window name on macOS: how to un-stick SSH to show next process?

I'm wondering whether others have experienced this issue (below in bold) and/or found a workaround: in macOS (any version that I've tried which provides Terminal access, so I'm assuming OS X on up; on any hardware), a Terminal or iTerm2 window gets named with the active top-level process until it ends or you quit it. Expected behavior for all systems with Terminal access, right?
When using SSH in Terminal or iTerm2 on macOS, the name of the remote machine populates the top of the window. Also expected. The unexpected comes when you exit out of the SSH session, and the name of the remote machine you had SSH'ed into persists in the window banner; there is no more visibility in the window banner of your current top-level running process, until and unless you close the window (losing some access to command history), and open a new window.
I've never seen this process-stuck behavior on the banner of a Terminal window in any other OS; various forms of Terminal on Linux distros exit out of SSH and get back to showing the top-level running process fine, as does CMD or PowerShell in Windows. What's going on with macOS, and why has this behavior never been addressed, at least as for as my limited DuckDuckGo-fu (or !G-fu) can find?
Has anyone else experienced this?
Insight welcome. Thanks!
There's no "process stick" going on.
Let's address several things here.
First, please note... "shell" != "terminal", and if you think it does, you are mistaken.
You state:
When using SSH in Terminal or iTerm2 on macOS, the name of the remote
machine populates the top of the window.
Yes, if the remote shell sets the terminal window title. Usually in a prompt. Sometimes in a shell initialization rc file. With ksh you even see people overloading things like cd(1), which is a little silly.
Then you state:
The unexpected comes when you exit out of the SSH session, and the
name of the remote machine you had SSH'ed into persists in the window
banner
Because the remote shell set the title of the terminal window and the local shell does not reset it when it regains control.
And finally:
What's going on with macOS, and why has this behavior never been
addressed, at least as for as my limited DuckDuckGo-fu (or !G-fu) can
find?
If you want whatever shell you are using to do something, configure it to do that thing. Otherwise, it will not do that thing. There's nothing to address... it's not broken.
macOS default init for ksh doesn't set any prompt at all, for zsh all that's set up is user name, machine name, and current $PWD, and bash is the same. None of them set the terminal window title.
Seems rather obvious what's going on.
So. If you want your terminal window titles to reflect this information:
the local shell needs to set the window title
the remote shell(s) need to set the window title
It seems you have the second one handled, so fix the first one. Most people do it by adding control codes to the shell prompt so that it changes the window as reliably as possible.
You may find this reference helpful.

Windows 10: command window does not close, but closes in Windows 7

i'm using windows 10 and trying to start an exe in diffrent folders sequentially. The idea is to use popen from subprocess and wait for the process to finish. The problem is, that the window does only close if I click on it or hit a key. On a windows 7 machine however the window is closing and subprocess.wait() finishes.
import os
import subprocess
for path in ["C:\tmp\", "C:\tmp2\"]:
os.chdir(path)
mywindow = subprocess.Popen(["my.exe",
#stdin=subprocess.PIPE,
#stdout=subprocess.PIPE,
#stderr=subprocess.PIPE,
#shell=True,
creationflags=subprocess.CREATE_NEW_CONSOLE,
env=dict(os.environ, **{"test":"AUTO"}))
mywindow.wait()
I used creationflags=subprocess.CREATE_NEW_CONSOLE, because I need to be able to start my.exe multiple times and be able to read the output on another console. But in some cases I want to wait for my process to end.
Update:
After eryksuns comment I'm pretty sure that this more of a windows problem than a python one.
On Windows 7 "my.exe" exits and wait() returns afterwards. On windows 10 however, I have to click somewhere on the screen or press any key, in order to close the console window "my.exe" opens. Afterwards the wait()returns. Disabeling the cmd quick edit mode had no effect.

Xamarin Studio fails to execute code with login shell in Mac Terminal

I'm new to Xamarin on the Mac, and I'm running into some issues running my code. I don't think it should matter, but I'm using the D language plugin to develop my code.
When Terminal is set to Shells open with: Default login shell (which is zsh in my case, but bash results in the same issue), hitting the execute button causes Xamarin Studio to pop up a Terminal window which closes before it can do anything, and then Xamarin Studio reports Cannot execute "blah". ScriptError. I added an infinite loop at the beginning of my program to make sure the shell isn't exiting because the program terminated quickly, and sure enough the program seems not to be starting at all.
If I instead tell Terminal Shells open with: Command (complete path): /opt/local/bin/zsh, the terminal happily opens up and the window is named correctly as "Xamarin Studio External Console" but of course nothing is executed except for the shell itself.
Any way to debug or fix this would be greatly appreciated!
MonoDevelop/XamarinStudio uses xterm by default. Dunno if that piece of info might help.

Command prompt gets stuck and continues on enter key press

Does anyone come across a scenario when the command prompt is running a process and then it gets stuck and the process is also sleeping.
Then when we press Enter key in the cmd window the process continues.
Is there any way to avoid this?
or can this be handled??
The other answers are wrong! The Windows console has a separate mode called "mark mode" for selecting text. In that mode the screen will be frozen, texts will go into the buffer and if the buffer is full the running process will be blocked
If quick edit mode is enabled (by default it's disabled in older Windows but enabled in Windows 10) then clicking inside the console window will activate mark mode and result in what you observed
It's very easy to accidentally click the console and stop the command. When you press Enter or Esc the selected text will be copied to clipboard and mark mode will be exited, therefore the process will run again. Priority is absolutely irrelevant here because if the buffer is full then the process is blocked forever until you exit mark mode, regardless of the priority. The console does nothing to change the priority when there are some inputs. Try opening an app that outputs a lot of data in the highest priority and click the console, the app will still be blocked indefinitely even if the CPU is in idle
Here's an example of QuickEdit mode setting in Windows 8 console:
To fix this you can disable QuickEdit mode if you don't need it. In this case copying will be more troublesome because you must open the context menu, select Edit > Mark. You can also disable QuickEdit mode by setting ENABLE_QUICK_EDIT_MODE with SetConsoleMode() if you're writing your own console application
See also
How and why does QuickEdit mode in Command Prompt freeze applications?
What does it do exactly if I click in the window of cmd?
Turn off Windows 10 console "Mark" mode from my application
If other processes are sucking all the cycles and have a higher prio, then your process might be stopped. A user input might just give it a prio boost, so it starts again. See Microsoft Docs at https://learn.microsoft.com/en-us/windows/win32/procthread/priority-boosts for more information.
It happened to me today while executing a batch file that includes TFSBuild.
I already received email notification from TFSBuild that it is successful, but somehow the batch file did not proceed to the next line.
I waited 1 hour.
I pressed Enter, Mark for Edit etc. but none of that worked.
Then I hit Ctrl+C to try to terminate the batch file.
When asked if I want to terminate, i entered N.
Weirdly enough, the batch file continued after that.

Resources