Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
29 views

Are 'kernel-modules' and 'GNU C Library' the same?

I am newbie in Linux and I am trying to understand the basics of the Linux OS structure. So: Are the 'linux-kernel-modules' listed in the output from 'lsmod' and 'GNU C Library' (about 2000 ...
0
votes
0answers
43 views

How to access data written in a socket without reading it [migrated]

I'm working on an embedded system having Linux. A client thread is writing some data in the socket but what server thread is reading on the other side isn't the same as it was written. Which is ...
1
vote
0answers
31 views

How to access a process descriptor that isn't the current one? [closed]

Is there any way to access a processes descriptor of a process that isn't currently running, preferably in C?
1
vote
0answers
22 views

How to analyze results after software-based fault injection campaign? [closed]

I am working on a software-based fault injection technique based on gdb to inject faults (bit flip) into a running program (c code). I have developed a tool to perform fault injecting at run-time. ...
0
votes
0answers
23 views

How does my application in Linux know how to find libraries in the common places [duplicate]

When I compile a simple C program for Linux, how does it automatically know where to find the standard C libraries when I run it? Take the simple Hello World program for example which uses printf to ...
0
votes
0answers
20 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:...
-1
votes
1answer
30 views

OpenSSL Crypto development libraries are not installed properly in required location

When I configure turnserver-3.2.3.95 in my CentOS, I meet the following problem. $ cd turnserver-3.2.3.95/ $ sudo ./configure more is /bin/more install is /bin/install pkill is /bin/pkill Use TMP ...
0
votes
0answers
11 views

How to get CPU and memory usage in C? (in Linux System) [migrated]

I wrote a C program is about vigenere encrypt and decode. And then, I want to add CPU and Memory usage in this program. However, I don't know what to add CPU and Memory code in this program. ※I ...
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 ...
0
votes
1answer
16 views

Launch interactive app from script

I have an application built in C that uses fgets to read user commands from stdin. I want my embedded linux system to launch this application on startup, and put the user in the terminal of this ...
-3
votes
0answers
36 views

how to share stdout between two C- and bash- processes

i need to create a pipe run the child process(exec to bash) and write some data into this pipe(from bash-script) and read data from another end of pipe in parenting C-process later i can't use pipe ...
1
vote
0answers
48 views

Why doesn't kernel module run my python script? [closed]

I know that we can call user space from Kernel Module, using the call_usermodehelper function. Prototype call_usermodehelper (const char * path, char ** argv, char ** envp, int wait) Where const ...
1
vote
0answers
41 views

Struct structure with method in linux source code [migrated]

I am reading android kernel code and I'm facing this kind of data structures , static const struct file_operations tracing_fops = { .open = tracing_open, .read = seq_read, .write = ...
0
votes
4answers
105 views

Deleting (some) comments from a C program

I need to use a bash script to delete full-line old-style comments from a C program, i.e., comments that begin (/*) and end (*/) on the same line, with no code on the same line.  This is an example of ...
0
votes
0answers
13 views

Errors uploading files using an ftp client written in C using sockets

I wrote an ftp client in C using sockets, and a convenient API made by hubenchang0515 on GitHub called libftpclient. I followed the demo.c file shown in the repository; when I'm using the put command ...
4
votes
1answer
196 views

mmap: effect of other processes writing to a file previously mapped read-only

I am trying to understand what happens when a file, which has been mapped into memory by the mmap system call, is subsequently written to by other processes. I have mmaped memory with PROT_READ ...
2
votes
1answer
33 views

What the branch machine op-code means (X86 architecture)?

I have a simple c code which is compiled and then the text code extracted using objdump utility. here is the dump file (A piece of dumped file): 0804841b <main>: 804841b: 8d 4c 24 04 ...
0
votes
0answers
87 views

execve(2) not launching system commands

I am trying to implement a container, and for that I create a process using the clone(2) system call with the appropriate flags: if ((child_pid = clone(child_main, process_struct.Stack + ...
0
votes
1answer
32 views

How to Run the command or script through any user in linux? [closed]

I am having a C executable in AIX system by which I can run the command through any user like root or system users. script having below permissions. On AIX server lrwsrwxrwx 1 root system 24 ...
0
votes
0answers
56 views

Permission denied opening pipe when i have all the permissions (redirecting input)

I have 2 users, user A and user B. The user B creates a named pipe with all permissions(rwxrwxrwx). USER B: execute ./test < input.txt (test is a program that writes from stdinput to the pipe). ...
0
votes
0answers
21 views

How to put telegram mtproto secret code in a file?

How to put telegram mtproto's secret codes in a file and then read it? first I made nano /etc/systemd/system/MTProxy.service and then past this code [Unit] Description=MTProxy After=network.target ...
1
vote
1answer
71 views

Invalid arguments when mounting with MS_SHARED

I am trying to mount the ext4 file system on /mnt into mount_dir which is a temporary directory I created using mkdtemp(2) with MS_SHARED then a remount with MS_PRIVATE, The idea is creating a mount ...
0
votes
1answer
42 views

Who initializes the address_space data structure?

I have searched all the linux kernel source code and filesystems but could not find the subsystem responsible for initializing the address_space object. The only thing I found was that the backing ...
0
votes
2answers
85 views

Why echo$?' returns 0 even though 1 is expected? [closed]

For the following program, I get 0 for echo$? even though I expect 1. int main() { return 1; }
-2
votes
1answer
65 views

can not read anything from serial port until i test something with “Screen” command [closed]

I think something wrong is in my setting (serial port, termios flag). when I run my code, it is waiting to receive data, but nothing happens, than I close my program and run screen command, it ...
0
votes
1answer
52 views

Notify when file read [duplicate]

How can I register to event that let me know when specific file is read in linux? Can implement in c or in bash /shell script
6
votes
1answer
424 views

Why doesn't mkfifo with a mode of 1755 grant read permissions and sticky bit to the user?

I'm creating a server and client situation where i want to create a pipe so they can communicate. I created the pipe in the server code with mkfifo("fifo",1755);: 1 for only user that created and ...
0
votes
0answers
34 views

How shell delivers user's input to program and shows program's output? [duplicate]

Since shell (for example, Bash) is just another program with its own stdin/stdout/stderr streams, how does it deliver user's input to running program? Here's simple program, that reads value from ...
1
vote
0answers
55 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
35 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
votes
1answer
54 views

Byte swap question (Bitwise operation) [closed]

I have seen some bitwise operation practice questions (in C language) and there was one I didn't understand: you had to swap the nth and the mth byte in a specifc integer "x" using only bitwise ...
1
vote
0answers
33 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
42 views

something wrong with my makefile about wildcard

I have a bunch of .c test source file in directory tests/. Now I want to compile and link them respectively and output the executable *.out in tests/. So I wrote a makefile, which didn't work. # ... ...
0
votes
1answer
58 views

Where does main function get allocated?

When concerned with a memory layout for a process, all function calls within the process get a new stack-frame into the stack. I'm not sure if this is true for main function as it seems like main ...
0
votes
2answers
61 views

Is there any way to know how many sockets have been created by a C program?

I have been running a C program which connects to a Redis database every once in a while. After running the program for a few hours it was displaying "Cannot create socket: too many files open". I'm ...
0
votes
1answer
37 views

Why does make regenerate the main executable file in this makefile?

I have the following makefile: ############################################################################################################################################ ############################...
-1
votes
1answer
49 views

Do we need to open a file to get its attributes?

int stat(const char *filename, struct stat *buf); int fstat(int fd, struct stat *buf); Do we need to open a file to get its attributes? To access the attributes of a file, do we need to access the ...
2
votes
1answer
37 views

Purpose of _LINUX_EXPORT_H macro

What is the purpose of defining _LINUX_EXPORT_H in include/linux/export.h? It seems to be defined in this file and never referenced anywhere else. Is it redundant? Link: _LINUX_EXPORT_H in torvalds/...
1
vote
1answer
49 views

MacOS's counterpart to Linux's unshare(2)

Does MacOS have a counterpart to Linux's unshare(2)? I'd like for the following to fail on both systems. #define _GNU_SOURCE #include <stdlib.h> #include <sched.h> int main() { #if ...
1
vote
1answer
101 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 ...
0
votes
0answers
28 views

How to empty the list of supplementary group IDs for a process?

When I create a child process, it inherits the supplementary gids of the parent. If the parent is a root, then the child has (0) as supplementary gid. This behavior is not desired. Is it possible to ...
2
votes
1answer
95 views

Prevent Bash from removing zero-bytes in double-quoted string?

I need to supply arbitrary bytes for an argv argument of a C program. However, if the bytes are put within double-quotes, the zero-bytes are removed as can be seen below: v="$(python -c 'import sys;...
1
vote
1answer
42 views

CPU statistics calculation algorithm

I too many search on internet to found algorithm calculated %Us , %Sy , %Id , ... on result of top command . but can not found any documentation . some documents like this or this calculate cpu ...
1
vote
1answer
102 views

Shell crash and how to debug it

As part of my C application running on Linux, I call a script using the system( ) library function. This script does a umount of a connected USB flash drive. Very rarely (1 in 7-8k) iterations, I see ...
0
votes
2answers
61 views

Trying to do a Proof of Concept of poisoning 'ls' binary to hide files and folders

I am currently trying to modify 'ls.c' source file in order to hide files and folders containing the word hidden. After doing some research, I've found that this could be possible by adding this code ...
0
votes
1answer
101 views

Read arbitrary amount of memory with process_vm_readv

For process_vm_readv the linux man page states: [...] (Avoid) spanning memory pages (typically 4KiB) in a single remote iovec element. (Instead, split the remote read into two remote_iov elements ...
3
votes
1answer
469 views

Determine free space available on a USB flash drive in C (linux)

I would like to figure out the available free space on a USB flash drive in a C program in Linux. I have earlier used system("df -h /dev/sda1") to figure it out but using system command in a Linux C ...
2
votes
1answer
87 views

Kernel can't find initrd?

When trying to mount ext2 I get this error: Creating 4 MTD partitions on "MPC8313RDB Flash Map Info": 0x000000000000-0x000000100000 : "U-Boot" 0x000000100000-0x000000300000 : "Kernel" 0x000000300000-...
9
votes
1answer
1k views

How different is compiling source code in Debian GNU/Hurd from Debian GNU/Linux?

I was trying to compile libnetfilter_conntrack source from github as it was requested by iptables while compiling iptables and as any of these were not available in the HURD software repo and ended up ...
0
votes
0answers
68 views

How to programmatically get a hostname's IP address on a local network in C?

I'm working on a project where I'd like to transfer data over TCP/IP sockets in a C program between two computers connected over WiFi to a home router, both are running Debian-based Linix ...