6,223 questions
3
votes
1
answer
112
views
Write only when child process expects input
I'm on my way to create a simple terminal. I have the following code to test bidirectional piping, where the parent process should only attempt to write when the child process expects it, however at ...
0
votes
2
answers
80
views
gcc/g++ compiler with POSIX thread model
I'm on Windows OS and in the past month I used to compile a C/C++ project in Qt Creator IDE using MinGW's gcc/g++ compilers based on POSIX thread model, i.e. compilers that were built with the option -...
1
vote
2
answers
77
views
Ignore patterns not found in ex substitute command
POSIX.1-2017 specifies two line-oriented file editing utilities: ed(1) and ex(1). ex is more efficient for noninteractive batch-editing because POSIX requires it to accept one or more file operands, ...
-1
votes
1
answer
138
views
R Package Development (on Linux) configure sh: 1: ./configure not found
In R package development (on Linux) with configure scripts, using shebang in the first line of the configure file as recommended and making the script configure executable via "chmod u+x ...
3
votes
1
answer
97
views
munmap shared memory with locked robust mutex makes it deadlock, why?
I need to use robust mutexes for IPC in case one of my processes crashes while holding a mutex locked. Definition is clear from e.g. man pthread_mutexattr_setrobust and I will not repeat it here.
I ...
0
votes
1
answer
78
views
How to know if a system supports "netinet/in.h" in CMake
I have noticed some embedded environments do not support the header netinet/in.h in C/C++ projects. Typically, they have some other header which defines a sockaddr_in struct in its place (e.g. in the ...
1
vote
1
answer
101
views
POSIX syscall query
I've been researching the POSIX specifications and I'm a little confused by them as to what they define as a syscall. Lets take fork() for example I know it got to be in the C library but I'm a ...
11
votes
1
answer
263
views
What's the difference between pthread_setschedparam and sched_setscheduler?
Suppose I want to set a thread to use a particular real time scheduling policy with a given priority. From what I can tell, there are at least two functions that accomplish this.
From the man pages on ...
0
votes
0
answers
15
views
Processing order in canonical mode
I am trying to figure out what exactly the POSIX specification stipulates for how characters are being processed in canonical mode. See https://pubs.opengroup.org/onlinepubs/9799919799/ chapter 11 &...
0
votes
1
answer
105
views
Process a .gcode/txt file to extract data into a .csv file with Applescript
Here's what I'd like to do: Process a .gcode file to extract certain data and then create a .csv file containing all this data.
For your information, this .gcode file is used on a 3D printer or laser/...
1
vote
0
answers
84
views
Why doesn't std::tolower(int) nor std::tolower(char, std::locale) convert Ç to ç? [duplicate]
From Linux/glibc, I have run some simple experiments to test how all char values are treated by std::tolower(int) -> int and std::tolower(char, std::locale) -> char. For my locale, I was ...
0
votes
2
answers
65
views
Copy and rename a file with AppleScript without changing its extension
This applescript allows me to extract the text I'm interested in from a .gcode file but actually creates a copy of the file before modifying the original file. I would like to save the file without ...
3
votes
1
answer
69
views
Why is sigaction sending the the raised signal ID twice?
The signal handler passed in sa_sigaction to sigaction receives an int signal id as parameter, but the context info received as second parameter contains the signal id as field again.
Is there a good ...
-1
votes
1
answer
134
views
Are `ln -f` and `ln -sf` atomic on Linux and POSIX? [closed]
On Linux, does ln --force atomically overwrite the target? In other words, during the time that ln --force runs, is it guaranteed that the file system is always either in the original state or in the ...
0
votes
1
answer
57
views
Comments in between POSIX shell script's function name and its body, problem?
I wonder if I may use comments in between POSIX shell script's function name and its body? This appears not to throw any problem in shellcheck and runs in Dash / Bash, but searching for this ...
0
votes
0
answers
20
views
chmod in c# for android fails to work. What to do?
public static void SetFilePermissions(string filePath, FileAccessPermissions permissions)
{
try
{
var fileInfo = new UnixFileInfo(filePath);
fileInfo.FileAccessPermissions = ...
4
votes
0
answers
80
views
async-signal safety of c++ classes
There is a limited number of functions that POSIX defines as async-signal safe.
See here.
This includes some fundamental functions such as write.
Since this is really a C standard (since unix is built ...
3
votes
1
answer
68
views
What is the point of XCloseDisplay() man page saying that it may generate a BadGC error, if the return value can only ever be 0?
I was making a return value check, but then I read the source code and found out that the function doesn't return the error, but just may or may not generate it (via XFreeGC(), I guess) and you will ...
1
vote
0
answers
110
views
How can I emulate Bash's command history scrolling functionality in C?
I'm trying to write my own terminal shell in C and want to know how I can register arrow-up and arrow-down presses to populate the current input line with a previously entered line? I'd like to do ...
3
votes
2
answers
187
views
How to capture STDOUT, STDERR and process PID, without creating zombies
I'm wrapping a terraform binary in a script, as a part of an enterprise solution. Therefore I need to take care of:
file log capture (separately STDOUT, STDERR for some post-processing analytics)
...
3
votes
1
answer
71
views
Why doesn't SigPnd change in /proc/<pid>/status?
I am trying to understand the signals in POSIX/Linux. I wrote this test.c program:
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
void handler(...
2
votes
0
answers
130
views
Process synchronization using advisory locking
I'm trying to do an exercise from Advanced Programming in the UNIX Environment where I need to:
Open a file that contains a counter.
Fork a process.
Have the parent and child increment the counter ...
4
votes
3
answers
305
views
Cannot use POSIX functions with -std flag with GCC?
My code uses nanosleep(). It compiles fine. And now if I try to compile it with -std=c23 flag, nanosleep() isn't recognized.
Any other major C standard version doesn't work. I tried using various ...
13
votes
4
answers
1k
views
Difference between fgetc() and read() function in C
While researching on file I/O in C, I came across two functions: fgetc() and read().
//code1.c
#include <stdio.h>
int main(void)
{
char ch;
ch = fgetc(stdin);
return 0;
}
//code2.c
#...
4
votes
0
answers
107
views
Issue in static variables inside a class where same shared object(.so) loaded twice in a single process in Linux environment [duplicate]
Issue Description: When using the dlopen(), static variables
inside a class are shared across the process. This means that when the shared object is loaded multiple times, it does not have an ...