From iOS 11 if we call system()
we get something like:
error: call to unavailable function 'system': not
available on iOS
system("reboot");
^~~~~~
/opt/theos/sdks/iPhoneOS11.2.sdk/usr/include/stdlib.h:195:6: note:
candidate function has been explicitly made unavailable
int system(const char *) __DARWIN_ALIAS_C(system);
^
1 error generated.
An alternative is to use posix_spawn
instead like this:
#import <spawn.h>
extern char **environment;
int run_cmd(const char *cmd)
{
pid_t pid;
const char *argv[] = {"sh", "-c", cmd, NULL};
int status = posix_spawn(&pid, "/bin/sh", NULL, NULL, (char* const*)argv, environment);
if (status == 0) {
if (waitpid(pid, &status, 0) == -1) {
perror("waitpid");
}
}
return status;
}
void your_function(void)
{
run_cmd("reboot");
}