Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.

Questions tagged [c]

C is a general-purpose computer programming language used for operating systems, games and other high performance work and is clearly distinct from C++. It was developed in 1972 by Dennis Ritchie for use with the Unix operating system.

Filter by
Sorted by
Tagged with
1 vote
1 answer
39 views

I'm trying to compile the drm-subtree of JSM because I want to enable the panfrost driver on the RockPro64 / KHADAS EDGE-V / RK3399. The code is here: https://github.com/jsm222/drm-subtree He improved ...
john_connor's user avatar
2 votes
1 answer
155 views

When using the set -e flag in Bash, then it's difficult to get user-friendly error messages (a stack trace) and it's difficult to add cleanup code that executes before your script exits with an error ...
user3207874's user avatar
0 votes
1 answer
148 views

So I am designing a feature to redirect log file if there are multiple processes of this very program are running. I guess this requires me to somehow get to know whether there exists yet unfinished ...
PkDrew's user avatar
  • 111
1 vote
1 answer
124 views

Assume the following C snippet showing a piece of error handling: #include <sysexits.h> #include <stdio.h> … int main(int argc, char argv*[]) { int retval=0; … if(3!=argc) { /* wrong ...
AlMa0r's user avatar
  • 1
26 votes
3 answers
2k views

The 'gmtime()' standard library function returns a struct that has days numbered 1-31, but months numbered 0-11. Why is that? Presumably there is some historic reason?
7 votes
1 answer
546 views

Are there any lists compiled that provide a list of linux system calls used per function in a standard glibc build? For example, free() requires mmap, munmap, mprotect, prlimit64, and brk. If ...
user30972097's user avatar
2 votes
2 answers
131 views

I’m trying to write a C wrapper to run a bash process. The goal of this wrapper is to apply a seccomp policy to restrict certain syscalls. Here is the code: #define _GNU_SOURCE #include <stdio.h>...
Liric Ramer's user avatar
0 votes
0 answers
107 views

We are two FreeBSD lovers and a stubborn system administrators. We are trying to project a phone based on FreeBSD for several months. Emanuel Vadot and Jesper Schmitz Mouridsen have enabled the ...
mister_smith's user avatar
0 votes
2 answers
124 views

If I open a fifo for reading+writing in blocking mode: fd = open("foo", "O_RDWR"); Then it blocks until someone on the other end opens it for either reading or writing. But how do ...
Ariel's user avatar
  • 117
0 votes
0 answers
65 views

Trying to move a window by grip-able button. On 2 other window managers, and no manager it works fine. Windows move anywhere you want pass display edge bounds. On GNOME Shell and Mutter(Gala) the ...
user748603's user avatar
0 votes
1 answer
66 views

I am testing FTRACE in Linux VM (ubuntu 24.04) the kernel is Linux VirtualBox 6.11.0-26-generic. I wrote a kernel module to register a hook (probe) to kernel tracepoint of signal_generate, here is the ...
wangt13's user avatar
  • 651
0 votes
2 answers
87 views

According to The Open Group Base Specifications Issue 8, on the rationale of the open() and openat() functions: The purpose of the openat() function is to enable opening files in directories other ...
Salubia's user avatar
0 votes
1 answer
84 views

I am working on a process that forks several times. To debug it, I am using a debug file for which I open a fd and which stays the same for all child forks. Then I have a function print_debug, that ...
Bastian's user avatar
  • 25
0 votes
0 answers
61 views

As a way to better understand Linux kernel structures, interacting with and pulling information from these (and also getting more experience coding in C), I've been building simple kernel modules to ...
genericuser99's user avatar
0 votes
0 answers
40 views

When I used the getenv() function to get the address of USER, I got 0x7ffceae5e923 but when randomly checking the address using gdb, the $USER variable was stored at 0x7ffffffffe90e [ I started a ...
KeShAw's user avatar
  • 23
2 votes
1 answer
53 views

I'm writing a special PAM module that is supposed to authenticate user with a password stored in kernel keyring. The key is added by running the following command as root: keyctl add user some-key 123 ...
Subtle Development Space's user avatar
0 votes
0 answers
35 views

When I execute the c file #include <stdio.h> #include <stdlib.h> int main(){ printf("before the system call. I am too excited!\n"); system("ps"); ...
KeShAw's user avatar
  • 23
0 votes
1 answer
68 views

If using only the C/++ Extension from Microsoft in Visual Studio Code, then how does preprocessing of includes & macros for autocomplete work? Many include headers (such as sys/statvfs.h), depend ...
mo FEAR's user avatar
  • 157
2 votes
0 answers
60 views

I'm struggling the following problem. I have an NFS v4.1 mount, where I have a directory with a couple of thousands files. I'm trying to list their names and types. Even with a minimal example program ...
dmk's user avatar
  • 21
6 votes
1 answer
1k views

I am learning about Linux kernel development. I have cloned into the stable branch of Linux. I watched a tutorial from Greg KH on youtube that explains you can use the checkpatch.pl script to find ...
Jeremy's user avatar
  • 185
0 votes
0 answers
96 views

I have 2 systemd services. a.service b.service b depends on a but I don't want to explicitly mention the dependency in b.service file. Instead I am waiting on the org.freedesktop.DBus.Properties....
nishad kamdar's user avatar
0 votes
1 answer
147 views

We have a system where we need the user to be able to permanently change the network settings from the interface (via our C code), that used to be achieved by generating a new dhcpcd.conf file and ...
John U's user avatar
  • 344
0 votes
0 answers
33 views

I am working a WAVE file playing with ALSA PCM interface in Linux, and I heard noise when I played the file quickly and partially. Here is my playing function. static int playback_function(uint8_t *...
wangt13's user avatar
  • 651
0 votes
1 answer
31 views

I am trying to use sd_journal_print_with_location() function. #include <systemd/sd-journal.h> int main() { sd_journal_print_with_location(LOG_INFO, "CODE_FILE=tst_file.c", "...
White Owl's user avatar
  • 5,297
2 votes
1 answer
310 views

I read in Advanced Programming in Unix Environment this: Line buffering comes with two caveats. First, the size of the buffer that the standard I/O library uses to collect each line is fixed, so I/O ...
SekstusEmpiryk's user avatar
0 votes
0 answers
115 views

I have multiple NIC's on my Ubuntu machine. $ ifconfig docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255 inet6 ...
rosewater's user avatar
  • 111
0 votes
1 answer
645 views

I have a small service written in C on Debian. This service automatically starts with Linux and does some file operations and other things as expected. The service prints some informational messages ...
puck's user avatar
  • 125
0 votes
0 answers
1k views

I'm trying to write my own pci-device driver on an Ubuntu system. The example I found says that I need: #include <linux/init.h> #include <linux/module.h> #include <linux/pci.h> I'm ...
DrageFabeldyr's user avatar
0 votes
1 answer
46 views

I am using Open File Description (OFD) owned locks on Linux (fcntl with command F_OFD_SETLK). After locking a file, I memory mapped it, and closed the file descriptor. Another process tried to lock ...
Érico Rolim's user avatar
0 votes
1 answer
252 views

I have NICE-DCV installed in RHEL-8.10 and as root doing a dcv list-sessions shows all sessions on the system. But if a user does dcv list-sessions then the output from that is only their session ...
ron's user avatar
  • 9,175
0 votes
1 answer
175 views

I have a question on how to setup the filtering as described in the following scenario: I see that systemd-resolved listens on port 53 and sends all the DNS requests to the real DNS resolvers. I am ...
Andrei Glingeanu's user avatar
3 votes
2 answers
310 views

I have files that contains multiple functions like below. file1.c: static void function1() { code } ... static void functionX() { code } ... static void lastFunction() { code } file2.c: ...
aWLW's user avatar
  • 133
1 vote
0 answers
158 views

I'm trying to write a kernel module in C on ArchLinux. Installing the linux-headers package gives me the version 6.10.5-arch1-1 but running uname -r returns 6.10.5-arch2-1 How can I install the ones ...
KtheVeg's user avatar
  • 183
1 vote
0 answers
235 views

I am doing research with Linux Power Management interactions with USB devices. Which is why I would like to be able to wake a qemu vm from suspend with a passed through USB device. I have been able to ...
Darrion Ramos's user avatar
1 vote
1 answer
174 views

Gedit matches brackets like { with } and tells us where the matching opening/closing bracket is. If it is more than 10000 characters, it says "Bracket match is out of range" instead. How ...
Some Student's user avatar
3 votes
2 answers
228 views

I have some code like this that has failed once on CI and once locally, though I cannot reproduce it reliably. The code is like this: #include <stddef.h> #include <signal.h> #include <...
Tavian Barnes's user avatar
3 votes
2 answers
2k views

On my journey to create a 16 EiB sized file, I encountered the following issue: POSIX defines files to have their size represented using type off_t, and that "blkcnt_t and off_t shall be signed ...
Semnodime's user avatar
  • 397
9 votes
1 answer
2k views

tldr: Does mtrace still work or am I just doing it wrong? I was attempting to use mtrace and have been unable to get it to write data to a file. I followed the instructions in man 3 mtrace: t_mtrace.c:...
TopherIsSwell's user avatar
1 vote
0 answers
135 views

I have written a program for an embedded Linux system(petalinux). It runs fine when started from the terminal or TCF debugger. However, I want it to run when the system starts, so I use the start-stop-...
user3219624's user avatar
1 vote
1 answer
659 views

I want to write a small Linux driver extension. More specific: I want to write all the communication between the host and a M.2-nvme-ssd into a userspace file. The nvme driver is pretty big though and ...
led's user avatar
  • 13
0 votes
0 answers
33 views

I know that /bin/bash has certain built-in protections that prevent the abuse of the Set-UID mechanism. So if I create a custom binary and execute it, it won't run with SUID 0 (refer the below image). ...
yellowspectre's user avatar
0 votes
0 answers
270 views

I was not sure where to ask this question, since it is a mix of both programming and Linux, but hopefully this is the right place. I have written a simple program, which I'm buffer overflowing. I have ...
r3k0j's user avatar
  • 15
1 vote
0 answers
132 views

I have seen it said that the Linux kernel is built with -fwrapv to define signed integer overflow as wraparound, potentially sacrificing a tiny bit of performance in return for preventing the ...
rwallace's user avatar
  • 111
0 votes
1 answer
414 views

I'm trying to generate a new library that includes another one I have created previously. In my current folder I have my source files inside a src folder and my headers inside an include folder. This ...
Ricardo Sisco's user avatar
38 votes
3 answers
7k views

I started studying old C code (Unix v6) and I'm wondering what is the purpose of a single # in the beginning of the .c file. For example from https://github.com/lsahn-gh/unix-v6/blob/master/sys%2Fken%...
g0mb4's user avatar
  • 701
9 votes
5 answers
2k views

I would like to print all my C comments to a separate text file. Using awk, sed, grep, or bash output all multi-line C comments between /* ... */ (inclusive) output lines with // comments Optional: ...
jwzumwalt's user avatar
  • 299
0 votes
1 answer
194 views

My distro is MX Linux (Debian) GCC was already installed with distro. I am trying to compile some open source code from Nir Lictman. His Minimalist C web server code compiles in his YouTube video. ...
xstack's user avatar
  • 105
0 votes
3 answers
602 views

Suppose we have a C program that uses the shared library. If you make changes to a shared library and rebuild it, all programs using that library will automatically receive those changes the next time ...
dsa14dfS's user avatar
0 votes
0 answers
174 views

If I write the rules, for example, in this form: ACTION=="remove", GOTO="serial_end" SUBSYSTEM!="tty", GOTO="serial_end" KERNEL=="ttyUSB[0-9]*", RUN+=...
alexanderzhirov's user avatar
1 vote
1 answer
535 views

OS is Debian. As per my question here: Is there a way to determine what process is rebooting a server? I wrote a kernel module to intercept the reboot syscall via modifying the syscall table. ...
cat pants's user avatar
  • 167

1
2 3 4 5
18