Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

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.

96 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
0answers
709 views

Portable way to get all thread ids running inside a process.

During the porting of an application form Linux to FreeBSD I came up with the following problem. I need to get all thread id of all threads running inside my application. In terms of PThreads, I need ...
4
votes
2answers
1k views

Bash shell launched by forkpty() spawns child processes that ignore SIGINT. Why and how do I ensure SIGINT is not ignored?

I have a C program that uses forkpty to execute a bash shell. I'm finding that the programs launched by this shell are launched with SIGINT ignored, so when I send a Ctrl-C to the shell they never ...
3
votes
1answer
652 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 ...
3
votes
0answers
550 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 ...
3
votes
0answers
467 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 ...
3
votes
1answer
2k 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 ...
2
votes
0answers
69 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 ...
2
votes
0answers
59 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 ...
2
votes
0answers
296 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 ...
2
votes
0answers
110 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 ...
2
votes
0answers
709 views

Unhide the hidden module in linux kernel

I coded a LKM which has a functionality of hiding itself from procfs and sysfs. The problem is when I try to unhide it I get the following error :libkmod: ERROR ../libkmod/libkmod-module.c:1882 ...
2
votes
0answers
827 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 ...
2
votes
0answers
276 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\" -...
2
votes
0answers
251 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". ...
2
votes
0answers
75 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 ...
2
votes
0answers
619 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 ?...
2
votes
0answers
307 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 ...
1
vote
0answers
16 views

Unable to print the message sent from user space C application to linux kernel module

I have developed a simple linux kernel module : #include <linux/init.h> #include <linux/module.h> #include <linux/fs.h> ssize_t exer_open(struct inode *pinode, struct file *pfile) {...
1
vote
0answers
16 views

How to make the php extension(.so) file portable with dependent libraries?

I need to make an php extension(.so) file which can be made portable. The created library works fine on one of my machines, but, when I send it to other machine, it does not load properly as a ...
1
vote
0answers
24 views

Do inotify watches automatically stop when a program ends?

Per man 7 inotify, there are a limited number of inotify instances (/proc/sys/fs/inotify/max_user_instances) and watches (/proc/sys/fs/inotify/max_user_watches). If inotify is set up using ...
1
vote
0answers
29 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(...
1
vote
0answers
48 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 ...
1
vote
0answers
114 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 ...
1
vote
0answers
48 views

Where to look for data type definitions?

Is there any reference material like man pages that informs on C datatypes? I thought this would give me something, but not: $ man size_t No manual entry for size_t $ man -k size_t size_t: nothing ...
1
vote
0answers
42 views

Own boot parameter in Linux kernel gives no outprint (Homework)

The task is to write a own boot parameter in the linux kernel that activates printk under the kernel initiation. The Linux kernel version that is edited is 4.16.7 (buildroot 2018.11.2) and my ...
1
vote
1answer
203 views

Optimal sharing of a ring buffer between processes

We're implementing an embedded Linux system and have to provide a live updating graph on a website that shows data coming from a background process in the system. The question is how to optimally ...
1
vote
0answers
17 views

Can I limit a process's access to specified files and stdout only without root?

I want to setup a server for students to upload C code. The server compiles C code, run the binary and shows output to students. Now I am having security concern. Students can upload any code, but I ...
1
vote
0answers
96 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 (...
1
vote
0answers
222 views

Retrieving the SO_INCOMING_CPU of a UDP Socket?

The socket API provides an SO_INCOMING_CPU option, the details of which are provided in the man page: SO_INCOMING_CPU (gettable since Linux 3.19, settable since Linux 4.4) Sets or gets ...
1
vote
1answer
50 views

file lock existence check on remote host

I want to check the existence of file lock on a file in gluster file system. So that I can see from any host that whether file lock is held by any process (remote or local) on file in gluster file ...
1
vote
0answers
140 views

Compiling module on OpenWRT: make can't find build directory

My setup: OpenWRT 18.06.1 Raspberry Pi 2 B Kernel 4.9.120 Attempting to build a very simple hello world kernel module results in the following error: # make make -C /lib/modules/4.9.120/build M=/...
1
vote
0answers
303 views

Reserve memory in RAM and in the desired physical position

I'm trying reserved 2GB in RAM, but i like reserved in the start memory, in the 0x00000000 position to 0x80000000, Can I do it? I read in the LDD3 that you can reserver spaces in the memory, but in ...
1
vote
0answers
56 views

Fakeroot on macOS tries to delete system directories

I’m having a problem with fakeroot on macOS. I created a pacman fork. When I’d like to delete a package, pacman tries to delete /usr/ instead of a subdirectory. On Linux, it is working fine, though. ...
1
vote
0answers
35 views

Is there a standard/accepted way for a plugin library to identify its location on disk?

I am working on a C program that has a plugin architecture. We build and package both .rpm and .deb packages. Some plugins have additional non-binary resources, such as image files, or script files ...
1
vote
0answers
204 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 ...
1
vote
2answers
747 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 ...
1
vote
0answers
190 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 .....
1
vote
0answers
911 views

Read serial data continuously and store it in a file or buffer

I am trying to read data continuously from serial port and save it to a buf and/or to a file. Also this data is a stream of HEX characters and not ASCII. I am using a CHIP which runs debian. I have ...
1
vote
0answers
506 views

Is there a way to tune TCP about packet loss and retransmission?

In a question of mine ("Does arbitrary manipulation of TCP connection flow cause problems?") I asked whether a willing delay in a TCP connection could cause some troubles. My HTTP proxy, between a ...
1
vote
1answer
312 views

Difference between behaviors of setrlimit and limit stack

I am seeing a difference of behavior when setting stack size from shell and from inside my c program. The issue is that I have a function which has a large set of local variables (large arrays). If I ...
1
vote
0answers
58 views

some characters show after put objects on amazon s3

I use libcurl to put objects on amazon s3 service. Here is my original contents in a.txt: aaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbb ...
1
vote
0answers
71 views

Can two android devices in different network(3g) comunicate themselves with ssh connection?

I have two rooted android devices with different isp (I use different 3g connection for them) and created a double ssh connection (I can with a public ip server) communicating both to this server (I ...
1
vote
1answer
1k views

libpcap missing

I’m trying to run a C program, but every time I try to run it I get this message: error while loading shared libraries: libpcap.so.0.8: cannot open shared object file: No such file or directory I've ...
1
vote
0answers
110 views

Limit program execution to a list of arguments

I would like that my Unix users can only run a specific command insecurecommand with a controlled list of arguments stored in a file. The only solution I have found at this time is to : Create a new ...
1
vote
0answers
4k views

GTK3+ and C++ on OSX - “No GSettings schemas are installed” error

I'm trying to run a C++ example with GTK3+ and GStreamer components on OSX. I can gcc compile the source with: gcc -o basic5 basic-tutorial-5.c 'pkg-config --libs --cflags gstreamer-1.0 gstreamer-...
1
vote
0answers
2k views

How to cause memory fragmentation on a Linux based embedded device?

Hardware ARM What am I trying to do: Answer: I am trying to create memory fragmentation on a Linux 2.6.31 based swapless embedded device. Why: Answer:I am trying to port some patches to Linux 2.6....
1
vote
1answer
819 views

How to trace process scheduling of certain process?

For a project at my university I am researching ways to trace, log and manipulate the process scheduling of certain processes. I would like to launch an number of applications, everyone in a single ...
1
vote
0answers
623 views

mod_rewrite: undefined symbol: lstat error

I compiled the mod rewrite for apache (version 1.3.0) however, when I try to run the server I have this error about mod_rewrite: Syntax error on line 27 of /home/myuser/apache/etc/httpd.conf: Cannot ...
1
vote
1answer
1k 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,...
0
votes
1answer
16 views

socket bind() errno 22 - no time-wait sockets

I am quite new to C & Linux and I tried to setup a TCP socket server for Data exchange with a C-Code I compiled and executed on a Ubuntu System. From a Tutorial I copied the following code (see ...