Commit Graph

18 Commits

Author SHA1 Message Date
Arthur Williams 2c2a7f54ab nohup: Open nohup.out WRONLY
Open nohup.out write-only instead of not specifying the access permissions
instead of getting undefined behavior (which probably results in stdout
not being writable).
2021-10-23 16:17:20 -07:00
Michael Forney d2824f5294 Revert "Do not use arg.h for tools which take no flags"
This reverts commit 9016d288f1.

Tools that have no options are required by POSIX to support "--" so
that conforming applications have a way to shield their operands from
implementations that provide options as an extension.

echo(1) is just an exception, so it is handled specially.

See OPTIONS in https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/V3_chap01.html#tag_17_04
2019-06-29 18:33:48 -07:00
Laslo Hunhold e92a1aef54 Handle { NULL } argv[] properly in manual arg-reduction
Thanks izabera for reporting this!
2017-08-05 23:50:39 +02:00
FRIGN 9016d288f1 Do not use arg.h for tools which take no flags
We've already seen the issue with echo(1): Before we changed it to
ignore "--", the command

$ echo --

did not work as expected. Given POSIX mandated this and makes most
sense, in the interest of consistency the other tools need to be
streamlined for that as well.
Looking at yes(1) for instance, there's no reason to skip "--" in
the argument list.
We do not have long options like GNU does and there's no reason to
tinker with that here.

The majority of tools changed are ones taking lists of arguments
or only a single one. There's no reason why dirname should "fail"
on "--". In the end, this is a valid name.

The practice of hand-holding the user was established with the GNU
coreutils. "--help" and "--version" long-options are a disgrace to
what could've been done properly with manpages.
2015-04-25 11:43:14 +01:00
FRIGN 6f207dac5f Don't return but _exit after failed exec*() and fork()
Quoting POSIX[0]:
"Care should be taken, also, to call _exit() rather than exit() if exec cannot be used, since
exit() flushes and closes standard I/O channels, thereby damaging the parent process' standard
I/O data structures. (Even with fork(), it is wrong to call exit(), since buffered data would
then be flushed twice.)"

[0]: http://pubs.opengroup.org/onlinepubs/009695399/functions/vfork.html
2015-03-09 01:12:59 +01:00
FRIGN b7c199e050 Include sys/stat.h in nohup(1)
I accidentally removed it, but it's needed to compile on OpenBSD.
2015-03-05 00:57:14 +01:00
FRIGN a6ee96af7c Audit nohup(1)
1) no need to include sys/stat.h
2) remove the enum which just added a layer too thick on this simple
   program
3) argc-style, other style
4) weprintf instead of enprintf, then save the error-message of
   execvp before and return the proper status.
5) write consistent "not reached" comment.
2015-03-04 22:39:12 +01:00
FRIGN 31572c8b0e Clean up #includes 2015-02-14 21:12:23 +01:00
FRIGN 7b6d918b78 Add mandoc-manpage for nohup(1)
and mark it as finished in README.
2015-01-28 23:55:57 +01:00
FRIGN 1436518f9d Use < 0 instead of == -1 2014-11-19 20:09:29 +00:00
sin de4a36957e Silence stupid warnings when building sbase-box 2014-11-17 10:52:24 +00:00
FRIGN eee98ed3a4 Fix coding style
It was about damn time. Consistency is very important in such a
big codebase.
2014-11-13 18:08:43 +00:00
sin 44b3ea8f76 Use _exit() instead of return if exec* fails 2014-11-13 17:06:41 +00:00
Hiltjo Posthuma 953ebf3573 code style
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-01 18:02:30 +01:00
stateless 7216a53a7e Remove unnecessary exit(1) in usage()
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2013-06-19 19:58:19 +02:00
Christoph Lohmann 4d38f60685 Eliminating the getopt disgrace. 2013-06-14 20:20:47 +02:00
Connor Lane Smith 572f5e926c simpler nohup 2011-06-24 08:33:08 +01:00
Connor Lane Smith f24772dcbb add nohup 2011-06-18 06:41:28 +01:00