News for hackers. Stuff that matters.
Re:The Rule of Silence (2006) by bjourne on Tuesday December 13, 2016 @05:12AM (#13165782)
It's often a stupid rule. If you have a process that is stuck, you type "kill <pid>" to kill it. But kill doesn't tell you if the process was killed or not, so you have to double-check with "ps <pid>" to see if it is still alive. If it is, you try again with "kill -9 <pid>".

I suspect the reason is that for most signals, kill can't determine if the signal was acted upon or not. But for KILL and TERM it could wait a few milliseconds and then print if the process is still alive or not.

Edit: those who are saying that I can write a wrapper script is missing the point. The point of computers is to be useful to their users, not to follow some philosophy people invented almost 50 years ago. Like if someone is bothered by kill showing messages, they can write a wrapper script (kill > /dev/null how hard is that?) or beg the developers to add a -q option to kill (like grep has) or write a new tool for sending signals.

Also, the program is called KILL so one could be forgiven for assuming it's main purpose is to KILL things...

Re:The Rule of Silence (2006) by anoother on Tuesday December 13, 2016 @05:15AM (#13165804)
I don't find this stupid. The job of `kill` is to send a signal, not to wait around afterwards.

Unix makes it trivial to write a wrapper script around `kill` that does exactly what you want -- that's the entire point.

Re:The Rule of Silence (2006) by verinus on Tuesday December 13, 2016 @06:57AM (#13166156)
then it should be named `sendKill` imho...
Re:The Rule of Silence (2006) by teddyh on Tuesday December 13, 2016 @07:07AM (#13166197)
Given the naming conventions of early Unix, you should be happy they didn’t name it “kl”.
Re:The Rule of Silence (2006) by tsukikage on Tuesday December 13, 2016 @08:19AM (#13166526)
> "those who are saying that I can write a wrapper script is missing the point"

No, it is exactly the point.

Unix gives you Lego pieces to build things from.

A bunch of small Lego pieces you can join however you like is way more useful than a giant chunk of Lego that someone has glued together into whatever lump they happened to need that day.

When you ask why your Lego bucket didn't ship with pieces preglued into exactly the combination you want today, people absolutely will reply saying you have all the pieces you need and you can just join them yourself.

Because that is the entire point of Lego.

If that wasn't what you wanted, perhaps consider a different kind of toy?

Re:The Rule of Silence (2006) by bjourne on Tuesday December 13, 2016 @10:32AM (#13167481)
I use computer to get shit done (tm). If I wanted to play with Lego, I'd go play with Lego instead. Yes I know I can write a wrapper, but why should I? Those who are bothered by kill spewing extra messages can also write a wrapper or use the damn C compiler and write their own kill utility.

That way, everybody wins. Both those who don't like Lego playing (me) and those who do (you).

> If that wasn't what you wanted, perhaps consider a different kind of toy?

I'd switch from GNU/Linux to something with a more sane design in a heartbeat! Unfortunately for me, the only free operating system began life as a Unix-clone. Thanks to an historical artifact more than a testament to the greatness of the "Unix philosophy".

Fortunately for me, there are a lot of people who have understood that thinking of an operating system as a jumbled bag of Lego bricks doesn't lead to good system design and are doing something about it (systemd and many more projects).

Re:The Rule of Silence (2006) by pif on Tuesday December 13, 2016 @05:55AM (#13165962)
> It's often a stupid rule.

By the way, I haven't down-voted you, but I think I understand why others did. Before calling stupid a pillar of a (programming) philosophy with decades of useful outcomes, you should stop and ask yourself whether it's just a matter of taste on your side or, even more likely, of ignorance.

Re:The Rule of Silence (2006) by michrassena on Tuesday December 13, 2016 @10:36AM (#13167521)
I think it's great that someone is questioning the way things have always been done, even it's just by calling it stupid. The hard part is coming up with something better. Unix at its core is still a product of the computing environment of the early 1970s. Not only that, it was a reaction to the complexity of Multics. What gave Unix an advantage at the time was how relatively easy it was to port to other architectures and how few resources it required. Universities and businesses could run it on cheap $50,000 minicomputers. It eventually outgrew a lot of its origins, but still. The rule of silence makes the most sense on a slow terminal or a teletype. Verbosity is wasteful and time-consuming in that environment.
Re:The Rule of Silence (2006) by pif on Tuesday December 13, 2016 @12:45PM (#13168749)
> I think it's great that someone is questioning the way things have always been done,

If you've taken the time to understand why generations of professional have done that way, and if you you have something else to propose, than the discussion is welcome and the result will be interesting in every case.

Otherwise, it's just a waste of time.

Re:The Rule of Silence (2006) by eeZah7Ux on Tuesday December 13, 2016 @12:11PM (#13168419)
Verbosity is wasteful and time-consuming in today's environment as well.

Most people on HN are developers and not as fluent as system engineers in shells and UNIX tools. The need for minimalist, "silent" UIs comes with fluency. This is also true for network engineers and database administrators.

Re:The Rule of Silence (2006) by pif on Tuesday December 13, 2016 @12:56PM (#13168846)
> The need for minimalist, "silent" UIs comes with fluency.

No, it comes from wanting to reuse the tool!

Would you like your browser to open plenty of pop-ups with messages like "Congratulations! The font XYZ was successfully loaded from C:\foo\bar" or "That's incredible! I looked for a JPEG on server www.qqq.com ... and it was there!"? No, you wouldn't. And I wouldn't like "mv" to babble every time it renames a file on the hard disk.

Re:The Rule of Silence (2006) by bjourne on Tuesday December 13, 2016 @08:42AM (#13166672)
But there is a limit to much respect you should pay to your elders. UNIX was invented over ten computer generations ago, and it's inventors couldn't possibly have imagined the world we live in today. And given that Windows is the dominant desktop OS, not Linux, the "decades of useful outcomes" favors my argument so I don't know who is the ignorant one.
Re:The Rule of Silence (2006) by pif on Tuesday December 13, 2016 @09:08AM (#13166821)
> Windows is the dominant desktop OS

So what? Is desktop computing all that matters? Networking, scientific computing, mobile telephone, don't they matter?

Unix was never meant for looking magic to clueless users; it was meant for programmers, i.e. for people who use the computer and not just some programs written by other people. And, in its realm, it has been brilliant! Not perfect, but very good!

By the way, here's a link to learn something more: https://blogs.msdn.microsoft.com/wsl/

Re:The Rule of Silence (2006) by bjourne on Tuesday December 13, 2016 @06:20PM (#13172236)
UNIX isn't dominant in the areas you mention now either (no, Android isn't UNIX). It has a niche among free software users and in networking devices but it is not common in other areas.

I.e. your "decades of useful outcomes" argument doesn't favor the point you are making because the opposite philosophy (a more verbose userland) has many times more "useful outcomes". Therefore, according to your own logic (which I don't subscribe to because I think popularity is a useless measure of sound design) you "should stop and ask yourself whether it's just a matter of taste on your side or, even more likely, of ignorance."

Re:The Rule of Silence (2006) by eeZah7Ux on Tuesday December 13, 2016 @12:14PM (#13168444)
On top of that, UNIX shell tools knowledge is not more required for casual desktop users (see Ubuntu) than batch files under windows.
Re:The Rule of Silence (2006) by JdeBP on Tuesday December 13, 2016 @12:42PM (#13168724)
> its inventors couldn't possibly have imagined the world we live in today

... except that they could and did. People were not lacking in imagination. A science fiction writer imagined the Internet-connected smart 'phone in 1976, and put it into a science fiction novel (calling it the "mini-sec") titled Imperial Earth. A decade before that, an engineer imagined windows, hypertext, the mouse, word processing, graphics, and video conferencing, and gave what was later called The Mother of All Demos in an ACM/IEEE conference in 1968.

Re:The Rule of Silence (2006) by annnnd on Tuesday December 13, 2016 @05:22AM (#13165839)
It is easy to work around this issue if it bothers you (wrapper script / display exit status in PS1). That's the whole point - it is easy to make applications talk if they are quiet by default, but it is much more difficult to make them be quiet and only talk when necessary if they are noisy by default.
Re:The Rule of Silence (2006) by adrianN on Tuesday December 13, 2016 @05:19AM (#13165820)
If you want that behaviour it is trivial to write a wrapper script that does this. If you don't want that behaviour, getting rid of it if it were built-in would be more difficult.
Re:The Rule of Silence (2006) by pif on Tuesday December 13, 2016 @05:44AM (#13165923)
> But for KILL and TERM it could wait a few milliseconds...

It wouldn't make sense:

1) the TERM signal can be trapped by the process, and "kill" has no right to assume that the process is supposed to quit;

2) the KILL signal is managed by the kernel and it just works (if it doesn't, then your kernel is buggy and you have more serious problems); even if "ps" shows the process as still alive after a "kill -9", you can assume it'd dead process walking.

Re:The Rule of Silence (2006) by zodiac on Tuesday December 13, 2016 @07:44AM (#13166358)
> Also, the program is called KILL so one could be forgiven for assuming it's main purpose is to KILL things...

I think this is the source of the problem. kill really is just for sending signals.

In the "Unix philosophy" there's no standard way to end processes, normally you send it SIGTERM and hope that it catches that, cleans up and exits. If it doesn't it could be a bug in the program, or maybe the program uses SIGTERM with slightly different semantics (eg Celery will wait for its children's tasks to finish, and does the "normal thing" of exiting as fast as possible when it gets two SIGTERMS); in any case I think the idea is that it's a weird, non-standard situation and the user needs to explicitly send SIGKILL (kill -9), since doing so might be dangerous.

Re:The Rule of Silence (2006) by nabanics on Tuesday December 13, 2016 @05:25AM (#13165858)
kill sends a signal, that's all it does. It doesn't care about what the process did with it.
Re:The Rule of Silence (2006) by TickleSteve on Tuesday December 13, 2016 @05:25AM (#13165857)
you already have a tool to check whether processes exist... 'ps'.

This is the essence of 'small, single purpose programs that work well with each other' rule.

Re:The Rule of Silence (2006) by bluetomcat on Tuesday December 13, 2016 @06:35AM (#13166082)
Actually, sending the zero signal to a pid as in `kill -0 <pid>` checks whether that pid exists and whether the calling process has permissions to send signals to it.
Re:The Rule of Silence (2006) by JdeBP on Tuesday December 13, 2016 @12:52PM (#13168808)
... at the point that the system call completed. There are no guarantees from that point onwards.

Interestingly, it would only take the addition of a pdopen() to something like FreeBSD's pdkill() to get enough for a tool that opened a process descriptor, sent a signal to the process, and determined (with poll() and pdwait4()) whether the process then exited; with the open-descriptor-style interface guaranteeing that it was always referencing the same process.

Re:The Rule of Silence (2006) by grive on Tuesday December 13, 2016 @05:34AM (#13165892)
kill sends a signal. It has no bearing over what the signal does and whether the result is what was expected.
Re:The Rule of Silence (2006) by nabanicu on Tuesday December 13, 2016 @05:22AM (#13165838)
kill sends a signal, that's all it does. It doesn't care about what the process did with it.