![]() |
Linux popen() alternative - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html) +--- Forum: Development (https://forum.cuberite.org/forum-13.html) +--- Thread: Linux popen() alternative (/thread-1903.html) |
RE: Linux popen() alternative - NiLSPACE - 05-05-2015 I'm really curious if it works. You said the Windows version with "start " in front of the command string didn't work, so it would be weird if this would work. RE: Linux popen() alternative - xoft - 05-05-2015 I'm sorry, I guess I brought in some confusion. os.execute("start <cmd>") works on Windows and it doesn't wait for the <cmd> to terminate (only it allocates a new console for the <cmd> and sometimes that console stays after <cmd> finishes, I'll have to find out more details) os.execute("<cmd> &") works and doesn't wait on Linux, at least on my RasPi. RE: Linux popen() alternative - NiLSPACE - 05-05-2015 According to the people here you can use "start /b " to not open a command prompt on windows. You could possible use: local cmdline = -- the command string if (cFile:GetPathSeparator() == "\\") then -- Windows cmdline = "start /b " .. cmdline -- Put "> nul" after this if you don't want to have the output in the current console. else -- Other platforms cmdline = cmdline .. " &" end os.execute(cmdline) RE: Linux popen() alternative - worktycho - 05-05-2015 Not all non-windows platforms are *nix based. What about mac classic? or are you going to not support it? RE: Linux popen() alternative - NiLSPACE - 05-05-2015 We should first have a function to detect on what platform we're at. Using cFile:GetPathSeparator is kinda hackish. I think Apple uses "open <cmdstring>". RE: Linux popen() alternative - worktycho - 05-05-2015 OS X does, I'm not sure what mac classic did. I can't find any documentation on creating a process, but what forum threads I have found indicate that it didn't have a shell to perform the command. And even if it does work on mac classic I have the wikipedia list of path separators up to quote ever more obscure OSs where this would have problems. My next candidate is VMS. RE: Linux popen() alternative - xoft - 05-05-2015 MCS doesn't compile for mac classic anyway, or does it? STR, what should be the return values of that function? If we let it return an enum osWidows / osLinux / osOSX, there will soon be an OS that is not covered (not a problem, just add a new value), but also an OS that is a sub-descendant of one of the main ones with some tricky little difference, such as osRasPiLinux. And suddenly things are getting out of hands. RE: Linux popen() alternative - worktycho - 05-05-2015 Not yet as far as I know. Its part of my probing to work out what is the exact limits of what we are and aren't willing to support. RE: Linux popen() alternative - NiLSPACE - 05-05-2015 Could this work? AString GetOperationType() { AString res = "unknown" #if defined (__WIN32__) res = "windows"; #elif defined(__linux__) res = "linux"; #elif defined(__APPLE__) res = "apple"; #endif #ifdef __arm__ res += " arm"; #endif return res; } Just to get some basic information about the operation system. RE: Linux popen() alternative - worktycho - 05-05-2015 PowerPC? SPARC? ARM64? Android? |