I have a project that uses automake to create the configure and all related files (I’m using autoreconf command to make all this stuff). So, I’m trying to set some conditional files to compile when the project is compiling for macOS (OS X), Windows or Linux. But it fails with the following: And th…
ioctl() call resets file descriptor to 0
Consider the following code: This snippet yields this: Why does my file descriptor get reset to 0? The program writes the stuff out to stdout instead of my block device. This should not happen. I expect my file_fd to be non-zero and retain its value. Answer Looks like you smash your stack. Since there are onl…
Running bash using posix instead of fork/execv
I have a CLI, one of the commands is entering into Linux bash shell. This is the code which does it using fork & execv: I want to replace the fork/execv and to use posix_spawn instead: But it doesn’t work. Any help? Answer Let’s look at what the code in the original fork/exec does: close all f…
How to write a bash script which calls itself with python?
Can someone explain how this bash script works? The part I don’t understand is “””:”, what does this syntax mean in bash? test running result: Answer That’s clever! In Bash, the “””:” will be expanded into only :, which is the empty command (it doesn…
Can’t output Python Print in PHP
I’m really stuck on this one, but I am a python (and Raspberry Pi) newbie. All I want is to output the print output from my python script. The problem is (I believe) that a function in my python script takes half a second to execute and PHP misses the output. This is my php script: I’ve included t…
How is the $ token treated when used under a label vs in a single line?
The NASM manual includes the following on the $ token in section 3.5: $ evaluates to the assembly position at the beginning of the line containing the expression and earlier in section 3.1 there is a note about source lines: NASM uses backslash () as the line continuation character; if a line ends with backsl…
Read/Write lock for linux kernel module
I’m trying to protect my list with data using read/write locks, i found solution in this thread: What’s the best linux kernel locking mechanism for a specific scenario But i can’t find needed headers for this solution, seems it is outdated, error: error: ‘RW_LOCK_UNLOCKED’ undeclared here (n…
local variables in linux
When we export a local variable declared within a current shell does it get passed to future sub shells,processes , child processes or future child processes? I was told it get passed to future sub shells. Is it correct? Answer This simple test will answer you by itself: Breaking it down: No export … &#…
Run find command from a bash file
Hi people: I’m making a xfe script to take a given directory as source file, use zenity to get output dir and perform some operations, for example: When the script is invoked, oggenc is not executed…any ideas? Solution: Based on answers bellow, this works as expected: Answer To make the variable $…
Linux: Reading file while other program might modify it
A program Foo periodically updates a file and calls my C program Bar to process the file. The issue is that the Foo might update the file, call Bar to process it, and while Bar reads the file, Foo might update the file again. Is it possible for Bar to read the file in inconsistent state, e.g. read first half