~sircmpwn/ctools

Fix nohup on darwin v1 PROPOSED

Max Leiter: 1
 Fix nohup on darwin

 2 files changed, 8 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/ctools/patches/9568/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH] Fix nohup on darwin Export this patch

---
 meson.build | 4 ++++
 src/nohup.c | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index fbf4840..0fa584f 100644
--- a/meson.build
+++ b/meson.build
@@ -51,6 +51,10 @@ else
	add_project_arguments(['-D_POSIX_C_SOURCE=200809L'], language: 'c')
endif

if host_machine.system() == 'darwin'
	add_project_arguments(['-D__DARWIN__'], language: 'c')
endif

add_project_arguments(cc.get_supported_arguments([
	'-Wundef',
	'-Wlogical-op',
diff --git a/src/nohup.c b/src/nohup.c
index acccb13..4624b7d 100644
--- a/src/nohup.c
+++ b/src/nohup.c
@@ -32,8 +32,11 @@ redir_to_nohup(int ofd, const char *home, const char *msg)
	if (fd < 0) {
		ret = 1;
		perror("nohup: open(\"nohup.out\")");

		#ifdef __DARWIN__
		int dirfd = open(home, O_RDONLY);
		#else
		int dirfd = open(home, O_RDONLY | O_DIRECTORY);
		#endif
		if (dirfd < 0) {
			perror(msg);
			return -1;
-- 
2.21.0 (Apple Git-122.2)
Can you clarify why this is wrong on Darwin? Do they not define
O_DIRECTORY? I'd rather define it to zero than add an ifdef with a
special Darwin case.