Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'system' is unavailable: ... on iOS error - with the recent Xcode 9 #19

Open
o-g-sus opened this issue Sep 28, 2017 · 5 comments
Open

Comments

@o-g-sus
Copy link

o-g-sus commented Sep 28, 2017

I have seen that people worked on that issue, but I still get an error with Xcode 9

s_file.c creates an error with system(cmdbuf);

static void sys_putpreference(const char *key, const char *value)
{
char cmdbuf[MAXPDSTRING];
snprintf(cmdbuf, MAXPDSTRING,
"defaults write org.puredata.pd %s "%s" 2> /dev/null\n", key, value);
system(cmdbuf);
}

@o-g-sus o-g-sus changed the title 'system' is unavailable: not available on iOS error - with the recent Xcode 9 'system' is unavailable: ... on iOS error - with the recent Xcode 9 Sep 28, 2017
@virusys
Copy link

virusys commented Sep 28, 2017 via email

@mariusjcb
Copy link

mariusjcb commented Oct 4, 2017

My fix (using posix_spawn) for this problem:

#include <spawn.h>

extern char **environ;

void run_cmd(char *cmd)
{
    pid_t pid;
    char *argv[] = {"sh", "-c", cmd, NULL};
    int status;
    
    status = posix_spawn(&pid, "/bin/sh", NULL, NULL, argv, environ);
    if (status == 0) {
        if (waitpid(pid, &status, 0) == -1) {
            perror("waitpid");
        }
    }
}

and call run_cmd(cmdbuf); instead of system(cmdbuf);

@danomatika
Copy link
Member

danomatika commented Nov 13, 2017

The fix is to simply not build s_file.c with the newer pd sources. This will be fixed in the next version of libpd which will come out soon, but you can try the current master if you need to be able to build/test for now.

@danomatika
Copy link
Member

danomatika commented Nov 13, 2017

Also, problems like these are better opened on the main libpd repository as this repo is mainly for hosting the iOS examples.

@NotAlexNoyle
Copy link

@mariusjcb Your fix is great, thank you. Has helped me a lot over the last few months.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants