ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi everyone!
I have a problem with a program that I am creating, I have uploaded it to github, https://github.com/miaumezu/pow, it 's supposed to kill all processes till it has permissions, but sometimes unlogs the user, sometimes closes windows, and sometimes it does nothing.
Thanks .
Generally speaking, the first step to debugging a program that gives different results "sometimes" is to determine what those "sometimes" are.
But your program just kills processes in numerical pid order, right? And it doesn't care what those processes are? I'm not sure what you expect it to do differently.
The word says it, the program is supposed to kill all processes that the user can kill, but it kills only some of them, if you try another time, it maybe close the user session, etc.
Well, gee, if the user session just happens to be early in the list of processes that the user can kill, and your program kills it, then how do you expect it to continue?
Generally speaking, the first step to debugging a program that gives different results "sometimes" is to determine what those "sometimes" are.
But your program just kills processes in numerical pid order, right? And it doesn't care what those processes are? I'm not sure what you expect it to do differently.
Yes, it is supposed to kill the processes ignoring what they are, I expect only a kind of bomb, it kills all the processes without looking what they are.
The word says it, the program is supposed to kill all processes that the user can kill, but it kills only some of them, if you try another time, it maybe close the user session, etc.
There is a user on LQ that has a tagline similar to "A program will never do what was intended, only what was implemented." This is the case here. This is what you implemented.
By blindly killing all user processes this is what will happen. The user session is a user process so killing it will close the user session. I notice that you are avoiding the process id of the program itself but if you kill the bash shell from which it was invoked it will also kill your program resulting in incomplete execution. You also don't check if there is a process 99999 or 99998 ... and so are trying to kill thousands of non-existent processes.
Your "program" is of no use to anyone in this state and should be removed from github. You should never upload anything that doesn't work or has never been tested or is fundamentally flawed in concept.
Your "program" is of no use to anyone in this state and should be removed from github. You should never upload anything that doesn't work or has never been tested or is fundamentally flawed in concept.
Because of that I am asking this, for correcting it.
Maybe you need to better define what should be killed and what shouldn't? No-one knows exactly what your program is supposed to be doing differently, and when asked, all you've said was "it's supposed kill processes". Which it already does. Edit: And "I was expecting a bomb". Which it already is.
yes, it sounds like you're going to have to put some checks in place to prevent it from killing the desktop/ window manger especially into your code. I even use that sometimes to kill my window manager whenever I lock it up, and can still use a keyboard that is.
as far as looking at your program, to maybe through you a bone, well, "404 Page not found", you must have killed that too.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.