Skip to content

Commit

Permalink
Merge pull request xbmc#2455 from ulion/fix_ios_startup_crash_on_popen
Browse files Browse the repository at this point in the history
[IOS] Fix popen crash during xbmc starting up, it may not work on ios
  • Loading branch information
ulion committed Mar 17, 2013
2 parents 8f3fecd + 519e7c6 commit 5155ff3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions xbmc/osx/DarwinUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ extern "C"
#endif
bool DarwinIsAppleTV2(void);
bool DarwinHasRetina(void);
const char *GetDarwinOSReleaseString(void);
const char *GetDarwinVersionString(void);
float GetIOSVersion(void);
int GetDarwinFrameworkPath(bool forPython, char* path, uint32_t *pathsize);
Expand Down
14 changes: 14 additions & 0 deletions xbmc/osx/DarwinUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@ bool DarwinHasRetina(void)
return (platform >= iPhone4);
}

const char *GetDarwinOSReleaseString(void)
{
static std::string osreleaseStr;
if (osreleaseStr.empty())
{
size_t size;
sysctlbyname("kern.osrelease", NULL, &size, NULL, 0);
char *osrelease = new char[size];
sysctlbyname("kern.osrelease", osrelease, &size, NULL, 0);
osreleaseStr = osrelease;
delete [] osrelease;
}
return osreleaseStr.c_str();
}

const char *GetDarwinVersionString(void)
{
Expand Down
4 changes: 4 additions & 0 deletions xbmc/utils/SystemInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,10 @@ CStdString CSysInfo::GetUnameVersion()
result += name.release;
result += " ";
result += name.machine;
#elif defined(TARGET_DARWIN_IOS)
result = GetDarwinOSReleaseString();
result += ", ";
result += GetDarwinVersionString();
#else
FILE* pipe = popen("uname -rm", "r");
if (pipe)
Expand Down

0 comments on commit 5155ff3

Please sign in to comment.