platform-independent

How to check if an arbitrary PID is running using Node.js?

放肆的年华 提交于 2019-12-09 02:17:07
问题 Is there some way to check if an arbitrary PID is running or alive on the system, using Node.js? Assume that the Node.js script has the appropriate permissions to read /proc or the Windows equivalent. This could be done either synchronously: if (isAlive(pid)) { //do stuff } Or asynchronously: getProcessStatus(pid, function(status) { if (status === "alive") { //do stuff } } Note that I'm hoping to find a solution for this that works with an arbitrary system PID , not just the PID of a running

Portable way to get file size in C/C++

别来无恙 提交于 2019-12-08 16:37:43
问题 I need to determin the byte size of a file. The coding language is C++ and the code should work with Linux, windows and any other operating system. This implies using standard C or C++ functions/classes. This trivial need has apparently no trivial solution. 回答1: Using std's stream you can use: std::ifstream ifile(....); ifile.seekg(0, std::ios_base::end);//seek to end //now get current position as length of file ifile.tellg(); If you deal with write only file (std::ofstream), then methods are

Qt portable IPC: only QSharedMemory?

前提是你 提交于 2019-12-07 07:57:20
问题 I'm looking for suggestions about choosing a portable way to achieve local IPC in a robust way, since i'm new to C++ and would like to avoid common pitfalls of fiddling with shared memory and locks; therefore I was thinking about message-passing style ipc. I was planning to use qt for other reasons anyway, thus i took a peek to Qt ipc options. if i understand correctly qt doesn't offer a completely portable message-passing ipc feature. it can use d-bus, but using it on windows would be a

How to ensure same float numbers on different systems?

僤鯓⒐⒋嵵緔 提交于 2019-12-05 23:17:03
问题 If I compile following c lines on windows and linux(ubuntu) I get different results. I would like to avoid. How can I do it? double a = DBL_EPSILON; double b = sqrt(a); printf("eps = %.20e\tsqrt(eps) = %.20e\n", a, b); linux output: eps = 2.22044604925031308085e-16 sqrt(eps) = 1.49011611938476562500e-08 windows output: eps = 2.22044604925031310000e-016 sqrt(eps) = 1.49011611938476560000e-008 On linux tested with gcc and clang on 32-bit and 64-bit system same result. On windows tested with gcc

Qt portable IPC: only QSharedMemory?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 18:19:18
I'm looking for suggestions about choosing a portable way to achieve local IPC in a robust way, since i'm new to C++ and would like to avoid common pitfalls of fiddling with shared memory and locks; therefore I was thinking about message-passing style ipc. I was planning to use qt for other reasons anyway, thus i took a peek to Qt ipc options. if i understand correctly qt doesn't offer a completely portable message-passing ipc feature. it can use d-bus, but using it on windows would be a problem. other ways are limited to embedded linux platforms (and i would like to port this thing to AIX). I

Capitalization and NoClassDefFoundError vs ClassNotFoundException

只愿长相守 提交于 2019-12-05 09:31:05
I'm seeing differences across platforms about when Class.forName() throws ClassNotFoundException and when it throws NoClassDefFoundError. Is this behavior well-defined somewhere, or have I stumbled across a bug? Consider the following code (which is a standalone java file in the default package): public class DLExceptionType { private static void printFindError(String name) { System.out.print(name + ": "); try { Class.forName(name); System.out.println("** no error **"); } catch (Throwable e) { System.out.println(e); } } public static void main(String[] args) { printFindError("DLExceptionType")

How to ensure same float numbers on different systems?

≯℡__Kan透↙ 提交于 2019-12-04 04:18:48
If I compile following c lines on windows and linux(ubuntu) I get different results. I would like to avoid. How can I do it? double a = DBL_EPSILON; double b = sqrt(a); printf("eps = %.20e\tsqrt(eps) = %.20e\n", a, b); linux output: eps = 2.22044604925031308085e-16 sqrt(eps) = 1.49011611938476562500e-08 windows output: eps = 2.22044604925031310000e-016 sqrt(eps) = 1.49011611938476560000e-008 On linux tested with gcc and clang on 32-bit and 64-bit system same result. On windows tested with gcc-mingw on 32-bit and visual-studio with 32-bit and 64-bit, also same results. In the example you give,

OS-independent API to monitor file system?

╄→尐↘猪︶ㄣ 提交于 2019-12-03 12:52:11
I would like to experiment with ideas about distributed file synchronization/replication. To make it efficient when the user is working, I would like to implement some kind of daemon to monitor changes in some directory (e.g. /home/user/dirToBeMonitored or c:\docs and setts\user\dirToBeMonitored). So, I could be able to know which filename was added/changed/deleted at every time (or within a reasonable interval). Is this possible with any high-medium level language?. Do you know some API (and in which language?) to do this? Thanks. Eric Drechsel A bonified answer, albeit one that requires a

Access the serial port in a platform-independant way [closed]

ε祈祈猫儿з 提交于 2019-12-03 09:02:17
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center . I have a task to create a program, that control a device over RS-232 from a desktop station. Currently I am at the planning stage and need some general help selecting a language and overall approach to the problem. The program should build and run under Linux (mostly Ubuntu) and Windows (XP, 7) on 32 and 64 bit Intel processors. The

What is os.linesep for?

只愿长相守 提交于 2019-11-30 11:54:48
问题 Python's os module contains a value for a platform specific line separating string, but the docs explicitly say not to use it when writing to a file: Do not use os.linesep as a line terminator when writing files opened in text mode (the default); use a single '\n' instead, on all platforms. Docs Previous questions have explored why you shouldn't use it in this context, but then what context is it useful for? When should you use the line separator, and for what? 回答1: the docs explicitly say