Skip to content

Commit

Permalink
Fix launchd cannot be run directly
Browse files Browse the repository at this point in the history
  • Loading branch information
asdfugil committed Feb 28, 2024
1 parent a8ad0f9 commit d6ff5a5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/jbinit/jbinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ struct paleinfo pinfo;
char ios15_rootdev[] = "/dev/disk0s1s1";
char ios16_rootdev[] = "/dev/disk1s1";

#define O_CLOEXEC 0x01000000

int main()
{
int fd_console = open("/dev/console", O_RDWR | O_SYNC | O_CLOEXEC, 0);
int fd_console = open("/dev/console", O_RDWR | O_SYNC, 0);
sys_dup2(fd_console, 0);
sys_dup2(fd_console, 1);
sys_dup2(fd_console, 2);
Expand Down Expand Up @@ -110,6 +108,13 @@ int main()

LOG("Closing console, goodbye!");

/*
Launchd doesn't like it when the console is open already!
*/
for (size_t i = 0; i < 10; i++)
{
close(i);
}
{
char **argv = (char **)dylib_data;
char **envp = argv+2;
Expand Down

0 comments on commit d6ff5a5

Please sign in to comment.