-
Notifications
You must be signed in to change notification settings - Fork 599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add some way for awesome.spawn to set G_SPAWN stdio flags. #3865
Comments
For some additional concrete real-world context, here's the chronology of my attempt to reduce the number of open FDs (from 2048!) while still keeping my log readable (chromium really hates my computer and complains about it every time a pointer event occurs.) |
Close stdout and stderr In this specific case, this is fine because chromium-based browsers open cat processes for their stdio These processes can die without the browser being killed by sigpipe. See awesomeWM/awesome#3865 for the (eventual) better way to do this.
Half un-related (this is a hack and not a proper solution): Replace |
|
I don't have that much time right now. Do you think you can do a pull request? You have all the context. A better alternative would be to implement the nonsense required for systemd cgroup based replacement for started notification to work. It's part of the same code (and both could be done at the same time). For that, some code in between the |
@Elv13 I'm sorry, I don't think I understand how using systems cgroups would effectively replace the current startup notifications or how they would fix the original issue by allowing the user to dictate where the process' sys{in,out,err} is connected? Also, I'm afraid however we end up deciding to implement this, I likely won't be much help, as I'm only mildly familiar with C and glib. I'm actively learning to read C, but writing it is a whole other story, and in terms of glib, I've gotten frustratingly familiar with it, but I've only used it though lgi in lua (almost certainly a much nicer experience than using it in C, and that's saying a lot because its quirks are annoying enough in lua) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Fixes: awesomeWM#3865 Currently works by allowing the exact strings "DEV_NULL" or "INHERIT" to be passed to return_std*. Documentation / error messages need to be fixed.
Fixes: awesomeWM#3865 Currently works by allowing the exact strings "DEV_NULL" or "INHERIT" to be passed to return_std*. Documentation / error messages need to be fixed. Signed-off-by: aarondill <[email protected]>
Fixes: awesomeWM#3865 Currently works by allowing the exact strings "DEV_NULL" or "INHERIT" to be passed to return_std*. Documentation / error messages need to be fixed. Signed-off-by: aarondill <[email protected]>
Fixes: awesomeWM#3865 Currently works by allowing the exact strings "DEV_NULL" or "INHERIT" to be passed to return_std*. Signed-off-by: aarondill <[email protected]>
Fixes: awesomeWM#3865 Currently works by allowing the exact strings "DEV_NULL" or "INHERIT" to be passed to return_std*. Signed-off-by: aarondill <[email protected]>
The specific flags in question are:
Documentation for these flags is found here: https://docs.gtk.org/glib/flags.SpawnFlags.html
Reason for feature:
Attempting to spawn a process (using
awesome.spawn
directly or indirectly ((awful.spawn.*))) with it's stdio pointing to/dev/null
is currently impossible (without manually spawning using lgi bindings to g_spawn_async_with_pipes, but this means snid detection can't be used).Use case:
My personal use case is to spawn certain noisey processes (for example: browser) without outputting their results to the console.
In my configuration, awesome's stdout and stderr are redirected to a log file so I can check for errors later, but this file also includes all processes spawned by awesome.spawn.
I tried using the
return_std{in,out,err}
parameters to avoid this issue, but ended up running out of FD and being unable to spawn processes. (super frustrating to debug...)Using the
return_std{in,out,err}
parameters, you could return parameters and close them, but most applications will die onSIGPIPE
(from closing stdout/stderr) so this is not feasible. Additionally, ifreturn_stdin
is false, stdin is connected to /dev/null anyways, so this becomes entirely pointless.Current implementation:
The options given for awesome.spawn are booleans that determine whether file descriptors should be returned.
If
false
ornil
is passed for stdout/stderr then the program will inherit the corresponding stream from awesome, and iftrue
is passed, a new fd is created and returned for use in the program (presumably using LGI).This makes it impossible to simply discard the output (redirect to
/dev/null
)note: stdin will be redirected from /dev/null by default (see: https://docs.gtk.org/glib/flags.SpawnFlags.html#child_inherits_stdin).
This instead makes it impossible to inherit stdin from awesome (unlikely situation, but perhaps a program needs console access?)
Desired result:
Ideally, there would be a way to indicate to
awesome.spawn
that stdout/stderr should not be returned, but rather redirected to/dev/null
.Possible Implementations:
return_std{in,out,err}
params to allow non-boolean parameters (See below for examples).Examples for second implementation (expand
return_std{in,out,err}
)The second implementation could be an integer with special values. For example:
-1
means inherit stream (only really useful for stdin, see note above)0
means return fd for stream (true does too for backward compatibility)1
means redirect to '/dev/null'false
would mean keep the GLIB default values (for backward compatibility)Or, it could be a string. For example:
true
means return fd for streamfalse
means keep the GLIB default values (for backward compatibility)"/dev/null"
means redirect to '/dev/null'"inherit"
means inherit stream (only really useful for stdin, see note above)g_spawn_async_with_pipes
.The text was updated successfully, but these errors were encountered: