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.

169 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6 votes
0 answers
2k views

Why is unistd.h named the way it is?

Similar in spirit to this question about the etymology of linux commands, I'm curious about the origin of the name of unistd.h. Does anyone know for certain what unistd.h stands for? If unistd.h was ...
Lukas Velikov's user avatar
4 votes
0 answers
209 views

Is there any solution to ltrace calls made by libs opened using dlopen()?

I wrote different two different types of queues. Bundled them in different .sos. I have a driver main.c which tests functions offered by those queues. main.c makes use dlfcn.h to load, unload required ...
Vishwajith.K's user avatar
4 votes
0 answers
5k views

How to change clang-10, llvm-10, etc to clang, llvm, etc.?

I use Spacemacs, and installed llvm-10, clnag-10, clangd-10, and all related packages, in Debian 10. Used the following command to install llvm $ sudo bash -c "$(wget -O - https://apt.llvm.org/...
tom_kp's user avatar
  • 43
4 votes
0 answers
737 views

Time measurment in Linux kernel: how are clock_gettime, gettimeofday and getrusage related?

I am trying to understand how time is measured by the Linux kernel. I tried to go through the kernel code, but I miss the big picture to understand the code that I'm reading, even if this article ...
Vincent's user avatar
  • 171
4 votes
0 answers
859 views

PortAudio appears to be broken on Debian/VirtualBox

I'm running Debian 9.2.1 in VirtualBox 5.1.30 on a Windows 7 host. I'd like to use the PortAudio library in a project so it can be used on multiple platforms, but I can't get it to behave even with ...
user avatar
4 votes
1 answer
3k views

ioctl: invalid argument for HDIO_GET_IDENTITY

I wrote a program to get the details of hard disk drive using HDIO_ ioctl calls. For writing program, I'm referring Documentation/ioctl/hdio.txt in kernel source(2.6.32). Here is my main part of ...
gangadhars's user avatar
3 votes
1 answer
180 views

SSH under pty still promts stdin from terminal

I am currently learning about the pseudo-terminal functionalities in C. I am able to create the master, slave end of the pty, after fork, I have set the stdin, stdout, stderr to fd slave , after exec ...
chellathurai's user avatar
3 votes
1 answer
258 views

What does it mean "new session has no controlling terminal"?

This reference says about creating a new session: The calling process is the leader of the new session, the process group leader of the new process group, and has no controlling terminal So I expected ...
ibse's user avatar
  • 295
3 votes
0 answers
147 views

Preprocess the Linux source code and save to another directory

Suppose I have the entire Linux source code in /tmp/linux-src. After menuconfig I want to do "some kind of gcc -E" where all the preprocessor macros other than #include are expanded so the actual ...
turbocoder's user avatar
3 votes
0 answers
793 views

How to provide user access to /sys/class/backlight/acpi_video0/brightness programmatically (udev?)

I control backlight through /sys/class/backlight/acpi_video0/brightness with a script (via sudo) that provides a simple script to increment/decrement, set, retrieve and restore last backlight setting ...
David C. Rankin's user avatar
3 votes
0 answers
1k views

Network interface with unknown speed

When I try to print the maximal throughput of my network interface, I receive an error: $ cat /sys/class/net/<interface>/speed cat: /sys/class/net/<interface>/speed: Invalid argument ...
gnivirht's user avatar
  • 151
3 votes
1 answer
1k views

Limit and measure VSS/RSS

I'm writing a program on Ubuntu 16.04, and it will fork, do some setups and exec another program. I need to: Limit the maximum VSS the program could use Limit the maximum RSS the program could use ...
Colera Su's user avatar
3 votes
0 answers
1k views

Hooking sys_execve on Linux kernel 4.6 or higher

Kernels lower than 4.6 use assembly stubs to harden the hooking of critical system calls like fork, clone, exec etc. Particularly speaking for execve, the following snippet from Kernel-4.5 shows entry ...
Usman Riaz's user avatar
2 votes
0 answers
375 views

Why do_exit() undefined?

I was building a kernel module for trying kthreads. A thread function after doing its works exits by calling do_exit(0). But when I am trying to compile the module, it is showing the error that ...
arka's user avatar
  • 243
2 votes
0 answers
83 views

What's the difference between ftrace and blktrace tracepoints?

For instance, we have /sys/kernel/debug/tracing/events/block/block_bio_complete and block_rq_complete which is basically IO completion trace points for ftrace, I believe. Using sudo blktrace -d /dev/...
Ken Y-N's user avatar
  • 253
2 votes
0 answers
172 views

How to find the memory address of the parameter(s) of a function

For context, I am attempting to exploit a buffer overflow as a practice exercise. I need to pass a parameter into a function via memory address. I have found the address for the function I would like ...
1Poseidon3's user avatar
2 votes
1 answer
60 views

How do I insert my own lib to other binaries in Linux?

My goal is developing a tool for educational purposes which logs commands on a system. Until now have found primitive ways to do this but all these ways can be easily bypassed so I had this idea to ...
Jugert Mucoimaj's user avatar
2 votes
0 answers
182 views

Minimal c program does more system-calls than expected

I am trying to learn more about strace. I use strace to understand the calls a c program makes. The c program is: void _start () { for (;;) { } } The program gets compiled with clang -...
Koronis Neilos's user avatar
2 votes
0 answers
1k views

Cannot open file with absolute path in Systemd Service

I have a .service which running my C++ application. My path is absolute path. It works when it is launch via command line but fails to open file when lauch via a systemd service. Output in service is ...
khanh8910's user avatar
2 votes
0 answers
222 views

Dynamic Linking when Migrating C++ Program from Solaris to Linux

The Problem I'm attempting to migrate a legacy application's build process from an older Solaris machine to Linux, specifically, RHEL 7.7. The application was originally built using Solaris Studio (...
Taylor Iserman's user avatar
2 votes
0 answers
47 views

Program to read the full RAM chip

I am trying to find a clever and simple way to read every address of memory. I am new to kernel development, but I presume this program will need to run in kernel space to have access to the whole ...
XDD's user avatar
  • 21
2 votes
0 answers
248 views

key binding running xdotool unexpected behaviour

I've programmed a key to run xdotool when it's pressed. But for some unknown reason xdotool is only sending keystrokes when the binded key is released, except when a non-active window is sent the ...
aaa's user avatar
  • 217
2 votes
0 answers
273 views

virtual address translation in Linux

I try to translate a virtual address to a physical address. I can translate the below address. 00400000-00401000 r-xp 00000000 103:04 14292394 /home/user/readMaps 00600000-00601000 r--p 00000000 103:...
karoha's user avatar
  • 21
2 votes
0 answers
1k views

Recover static library from executable

I have an existing executable for which a small amount of source code has been lost. In particular, the executable uses a few functions from a static library, and the source code for that library is ...
maldata's user avatar
  • 145
2 votes
0 answers
378 views

inotify stops reporting events

I am using inotify in a program written in C; it closely follows the example in man 7 inotify. The steps are essentially: /* setup */ int fd = inotify_init1(IN_NONBLOCK); int wd = inotify_add_watch(...
user001's user avatar
  • 3,688
2 votes
0 answers
443 views

seteuid fails even when all UIDs are 0

I have some C++ code on a Linux machine whose purpose is to run some code as an arbitrary user. #include <sys/capability.h> #include <unistd.h> void doAsUser(uid_t uid) { if (...
Iconmaster's user avatar
2 votes
0 answers
559 views

No such process (3) when not connected to a network (AF_ROUTE)

When I am connected to a network, I can send a struct rt_msghdr* to the kernel and receive a corresponding route. However, when I disconnect from the network and try to send the same route message ...
TekuConcept's user avatar
2 votes
0 answers
95 views

non-root access to physical blocks occupied by a file

ioctl() and FIBMAP can be used to determine the physical blocks occupied by a file, given logical blocks obtainable via stat(); however, root access is required. Why is root access necessary for ...
user001's user avatar
  • 3,688
2 votes
0 answers
346 views

Portable serialization of data in the Linux kernel

Is there really no functions / macros in the Linux kernel for portable serialization of integers (and other data types) to byte arrays? I would think that this must be such a common use case. For ...
mallwright's user avatar
2 votes
0 answers
381 views

Does SO_ATTACH_FILTER reset the socket's receive buffer?

If a filter is already set and there are unprocessed packets in the sockets receive buffer will calling SO_ATTACH_FILTER to set a new updated filter flush the buffer, i.e is it the same as BSD's ...
C.Sutherland's user avatar
2 votes
2 answers
2k views

select(2) on FIFO on macOS

On Linux the included program returns from select and exits: $ gcc -Wall -Wextra select_test.c -o select_test $ ./select_test reading from read end closing write end first read returned 0 second read ...
Steven D's user avatar
  • 46k
2 votes
0 answers
434 views

How to create a device file and simulate behaviors of the Pseudo-devices?

I am trying to create a device that accept input and generate special output. To make it simple, say I want to create a device which accepts any input (like /dev/zero) and writes 00 ff 00 ff 00 ff .....
Eric Stdlib's user avatar
2 votes
0 answers
1k views

Emscripten fundamentally incompatable with clang on linux

A long time ago I wrote a really crude and primitive shell in C++, and I only just recently discovered asm.js, so I thought it'd be neat to try to compile and run it in a browser, but I can't because ...
user avatar
2 votes
0 answers
351 views

LFS 7.10 - why am I getting an error when using make command for expect-5.45

I am trying to compile expect-5.45 for LFS everything works until I use the make command, below is the output of using the make command: gcc -DPACKAGE_NAME=\"expect\" -DPACKAGE_TARNAME=\"expect\" -...
roberthayek's user avatar
2 votes
0 answers
406 views

how to build kernel-tools-4.2.xx.rpm and kernel-ltools-libs-4.2.xx.rpm

I am trying to upgrade Centos-7 kernel (kernel-3.10) to (Kernel-4.2.6) and for that I downloaded kernel from kernel.org and create rpm for the custom configuration (arch x86_64)using "make rpm". ...
Vishwanath Jadhav's user avatar
2 votes
0 answers
99 views

Look up documentation on C types?

I'm reading over documentation on concurrency in C and trying to learn how to do things concurrently. As I'm reading, I'm coming across types I've never come across before like tss_t, etc. Is there ...
Naftuli Kay's user avatar
  • 39.5k
2 votes
0 answers
695 views

How can I compile minix when I make changes in libraries

I am looking for a way to compile minix. The make hdboot command seems to do nothing with the directories under /usr/src/lib. I changed only one .c file in syslib. Do I have to do make world for this ?...
byksl's user avatar
  • 21
2 votes
0 answers
319 views

Command-line file reader (like “less”) that can tell the line where the user stopped reading

[Context] I'm developing a little app, as a hobby to learn ncurses, that catalogs and lists and searches within a set of documents (for now, they are the HOWTOs from TLDP). The most tricky part of ...
beder's user avatar
  • 121
2 votes
1 answer
2k views

Difference between maximum resident set size as reported by /usr/bin/time vs. getrusage?

I ran the command a.out like this: $ /usr/bin/time -f"%M" ./a.out a.out also uses the function getrusage() and prints: printf("%ld",ru.ru_maxrss); where the first ru is the struct. When I run it,...
Dervin Thunk's user avatar
  • 3,509
2 votes
1 answer
713 views

Compile OS with gcc and ld on Linux

I'm practicing operating system development and am having trouble getting gcc and ld to produce pure binary without any metadata or section labels. For example: int function(){ return 100;} would ...
raystubbs's user avatar
  • 121
1 vote
1 answer
150 views

Reboot command doesn't invoke reboot system call?

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
  • 405
1 vote
0 answers
44 views

PTRACE_PEEKTEXT ptrace: Input/ouput error

I try to read the values from memory with using PTRACE_PEEKDATA. To find the memory address of specific line I am using with objdump - objdump --dwarf=decodedline ./exe_filename and got the output: ...
Aviel15's user avatar
  • 11
1 vote
0 answers
142 views

Linux TCP/IP kernel stack and VFS interaction

I'm reading the Linux kernel implementation of the TCP/IP stack. Everything was ok till I encounter this figure while reading TCP/IP architecture, design and implementation in Linux As you may see ...
ca-hercor's user avatar
1 vote
0 answers
2k views

Compiling CFLAGS in a Yocto Recipe File

Issue: I have 2 macros I added in a c file and I have 2 machines. Using Yocto recipe I wish to build the code with specific macros for specific machines. Breaking down the issue in sub parts - hello.c ...
Nathan's user avatar
  • 21
1 vote
0 answers
87 views

create PAM converstation

I tried to create a simple PAM module, that print some message, wait X second and return the PAM_SUCCESS status. Firstly I tried with this script: #include <security/pam_appl.h> #include <...
Atisom's user avatar
  • 71
1 vote
1 answer
62 views

How do unix systems call into an application?

I am currently implementing a C runtime library for the Arm64 platform, and I am unsure which assumptions I can make about the environment at the precise point that the application is executed (what ...
lte678's user avatar
  • 11
1 vote
0 answers
38 views

facing isue in UDP multicasting after changing ip of the device

we have a requirement for UDP multicasting in our project using Linux 4.1 kernel with static ip address. basic UDP multicasting using sendto function to send data is working fine with device static ip ...
Rajesh's user avatar
  • 11
1 vote
0 answers
126 views

Read the value from a virtual memory address in a program every frame

I've been trying to write a program in C that reads the value of a virtual memory address in a game so I can tell when it's loading. This is pretty easy to do on Windows but I can't seem to find much ...
Loomeh's user avatar
  • 11
1 vote
0 answers
80 views

Authenticating user groups with PAM in C

I am writing a program that allow certain users and user groups to not require authentication through PAM. I want to use the pam_access module but am fairly new and can't find good documentation for ...
Alex S's user avatar
  • 11
1 vote
0 answers
262 views

ioctl SIOCGIWSTATS signal level constantly 0

I have a block of C code that gets a variety of information about a network interface, namely the SSID and the signal level in dBm: #include <ctype.h> #include <errno.h> #include <linux/...
Jack828's user avatar
  • 11