How to pass arguments to the __code__ of a function?

I am completely against this use of __code__. Although I am a curious person, and this is what someone theoretically could do: code # This is your code object that you want to execute def new_func(eggs): pass new_func.__code__ = code new_func(‘eggs’) Again, I never want to see this used, ever. You might want to look … Read more

how to correctly use fork, exec, wait

Here’s a simple, readable solution: pid_t parent = getpid(); pid_t pid = fork(); if (pid == -1) { // error, failed to fork() } else if (pid > 0) { int status; waitpid(pid, &status, 0); } else { // we are the child execve(…); _exit(EXIT_FAILURE); // exec never returns } The child can use the … Read more

Using nodejs’s spawn causes “unknown option — ” and “[Error: spawn ENOENT]” errors

After lots of trying different things, I finally had a look at what “npm” actually is on windows, and it turns out to be a bash script called npm, as well as a windows-native batch script called npm.cmd (no idea why it’s .cmd, that should be .bat, but there you have it). Windows’s command resolver … Read more

Grabbing output from exec

You have to create a pipe from the parent process to the child, using pipe(). Then you must redirect standard ouput (STDOUT_FILENO) and error output (STDERR_FILENO) using dup or dup2 to the pipe, and in the parent process, read from the pipe. It should work. #include <stdio.h> #include <stdlib.h> #include <unistd.h> #define die(e) do { … Read more

Compile PyPy to Exe

There is no ready-made way or tutorial on how to do create an EXE from a program using the PyPy interpreter, as far as i know. And it’s not exactly trivial to get things going, i am afraid. In principle, there are two ways to consider for using PyPy’s translations to get a EXE file, … Read more