Use os_log to report get_argv failures on Apple
This commit is contained in:
parent
9ff9e50936
commit
65d97e2379
2 changed files with 11 additions and 1 deletions
|
|
@ -8,6 +8,9 @@
|
|||
#include "shlex.h"
|
||||
#include "utils.h"
|
||||
#include "launcher.h"
|
||||
#ifdef __APPLE__
|
||||
#include <os/log.h>
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
|
|
@ -46,6 +49,11 @@ get_argv_from(const char *filename, const char *argv0, argv_array *final_ans) {
|
|||
char* src = read_full_file(filename, &src_sz);
|
||||
if (!src) {
|
||||
if (errno == ENOENT || errno == ENOTDIR) return true;
|
||||
#ifdef __APPLE__
|
||||
int saved = errno;
|
||||
os_log_error(OS_LOG_DEFAULT, "Failed to read from %s with error: %{darwin.errno}d", filename, errno);
|
||||
errno = saved;
|
||||
#endif
|
||||
fprintf(stderr, "Failed to read from %s ", filename); perror("with error");
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,8 +55,10 @@ log_error(const char *fmt, ...) {
|
|||
if (!use_os_log) { // Apple's os_log already records timestamps
|
||||
fprintf(stderr, "[%.3f] ", monotonic_t_to_s_double(monotonic()));
|
||||
}
|
||||
// To see os_log messages from kitty, use:
|
||||
// log show --predicate 'processImagePath contains "kitty"'
|
||||
#ifdef __APPLE__
|
||||
if (use_os_log) os_log(OS_LOG_DEFAULT, "%{public}s", sanbuf);
|
||||
if (use_os_log) os_log_error(OS_LOG_DEFAULT, "%{public}s", sanbuf);
|
||||
#endif
|
||||
if (!use_os_log) fprintf(stderr, "%s\n", sanbuf);
|
||||
#undef bufprint
|
||||
|
|
|
|||
Loading…
Reference in a new issue