Comments (5)
I'm not actually sure where/when we could safely do this. Even AppDomain.CurrentDomain.ProcessExit
isn't really safe since there might be other handlers that expect to be able to use System.Terminal.
from cathode.
Is it possible to add a method that can be called that resets it? This way I can call it as I know I terminate.
from cathode.
That sounds reasonable.
from cathode.
@Thraka For your use case, would it be acceptable if the cleanup method would perform terminal state cleanup and also exit the process immediately after? This would greatly simplify matters in the library since I would not need to care about users calling the cleanup method and then trying to use the library after.
It might look something like this:
static class Program
{
static void Main(string[] args)
{
using (var lifetime = TerminalLifetime.Create())
{
// ... work ...
if (workFailed)
lifetime.ExitCode = 1; // defaults to zero
}
// lifetime.Dispose() called here, cleans up terminal state and exits
}
}
To simplify this, I'd probably also provide a package that works similarly to DragonFruit, i.e. it generates the real Main
for your application, takes care of the TerminalLifetime
for you, and calls your entry point method.
PS: I know it's been a while since this issue was opened... I'm only now getting around to continuing the project with .NET 6 being out.
from cathode.
Resolved in 443eff9.
For your use case, would it be acceptable if the cleanup method would perform terminal state cleanup and also exit the process immediately after? This would greatly simplify matters in the library since I would not need to care about users calling the cleanup method and then trying to use the library after.
I'll spin this off into a separate issue.
from cathode.
Related Issues (20)
- Support `DECARM`
- Support rectangular area sequences (`DECFRA`, `DECERA`, etc) HOT 2
- Consider formally dropping Windows console host support HOT 2
- Upgrade to `net7.0` target framework (.NET 7)
- Get rid of remaining avoidable allocations in `ControlSequences`
- Support `OSC 9 ; 9` and `OSC 7` for reporting the working directory HOT 1
- Handle cancellation of `TextReader`/`TextWriter` access resiliently
- Use `System.Drawing.Size` and `System.Drawing.Color`
- Wrap `FlushAsync(CancellationToken)` in `SynchronizedTextWriter` (.NET 8)
- Upgrade to .NET 8
- Build samples separately from core libraries HOT 1
- Support for image/graphics control sequences
- Write the 2nd progress report HOT 1
- Review the list of terminal emulators we support
- `ChildProcessReader` can bubble up internal exceptions to `ChildProcess.Completion`
- `ChildProcess.Kill()` can let internal exceptions through
- Long term: Rewrite the native support library in Zig
- Move `UnixCancellationPipe` logic to the native library
- Support musl-based systems (e.g. Alpine) HOT 5
- Write the 3rd progress report HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cathode.