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.

87 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
1answer
817 views

Can I add iptables rule from the inside of a C Linux program only with capabilities or do I need necessarily root?

I need to add an iptables rule from the inside of a C Linux program. How should I do? Do I need root privilege or can I just grant some capabilities? I tried granting CAP_NET_RAW+iep and using popen(...
4
votes
0answers
616 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 ...
3
votes
1answer
595 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
469 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
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 ...
3
votes
2answers
997 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 ...
2
votes
0answers
46 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
58 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
249 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
418 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 ...
2
votes
0answers
630 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
734 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
260 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
241 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
615 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
306 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
57 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
43 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
36 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
128 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
68 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
1answer
43 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
126 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
299 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
51 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
80 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 ...
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
187 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
682 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
163 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
819 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
480 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
243 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
53 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
989 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
109 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
812 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
614 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
0answers
11 views

How to connect USB keyboard to BeagleBone Black in my own kernel and root file system?

I built uboot, linux kernel and root filesystem for beaglebone black. I have logitech k120 for business usb keyboard. In menuconfig of kernel i selected logitech keyboard driver, usb driver, usb ...
0
votes
0answers
16 views

USB Linux API: call ioctl requests from user space app

I want to create Linux app responsible to get/set some usb settings especially settings responsible of followings: USB ports USB Host controller and USB driver USB devices I followed the linux api ...
0
votes
0answers
12 views

How to choose the C runtime library that will be included in the system image generated by Yocto?

As you all know, setting TCLIBC (eg. uclibc) in some distroX.conf will choose the C library with which the system is built (The compilation toolchain is going to build the system's packages with that ...
0
votes
0answers
22 views

Solaris: internal compiler error: Failure while writing SunIR file?

Today our Solaris box started randomly failing to build our company software product. It's a fairly large build of hundreds of .c files. The error the Solaris C compiler cites: (On a random file in ...
0
votes
0answers
29 views

Cannot bind TCP/TLS listener socket to addr XX.XX.XX.XX:3478

After installing and configring turnserver on a CentOS-7.X server, I meet the following poblem. $ ./turnserver ... ... 0: Cannot bind TCP/TLS listener socket to addr 39.39.39.39:3478 0:...
0
votes
0answers
13 views

Howto unload and load or reload translation files using gettext and the libintl library

In the Minetest game project there is the claim that one cannot use gettext because of the lack of dynamically loading translations. My question would be howto unload or reload translation files ...