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
0
votes
1answer
13 views

Check the actual glibc version used

I want check the glibc version used by toolchain to build code for the target system (ARM). In toolchain directory I tried strings /sysroot/lib/libc.so.6 | grep GLIBC the output is GLIBC_2.4 ...
1
vote
0answers
10 views

How to set an external task's state? [migrated]

I am writing a system call in the Linux kernel for a hobby project I am working on, and for this system call, I need to be able to put to sleep a bunch of processes that I generate in the system call. ...
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 ...
0
votes
1answer
37 views

strace does not list /etc/hosts in ping/host command in CentOS 7

I was reading https://zwischenzugs.com/2018/06/08/anatomy-of-a-linux-dns-lookup-part-i/ and on the author's Debian/Ubuntu system /etc/hosts is used. But when I do strace under CentOS 7, I don't see ...
1
vote
0answers
13 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
1answer
36 views

Preprocessing a C header file

I have a large header file which has many sections that are included or omitted depending on whether certain names are defined in the file. For example lines like- \#define A \#define B 2 ... \#ifdef ...
0
votes
1answer
30 views

Restrict child process 's cpu and ram usage by parent process using C/C++ in Linux

I am trying to create child processes from parent processes.I want to restrict CPU and RAM usage of the child processes using C/C++.Is there is a way to do it?
0
votes
1answer
61 views

Bash parallel processes have turned off the system?

I have a remote controlling server which I use to automatically executing commands/scripts etc to all my nodes in series. To increase the performance and speed I wanted to run it in parallel. I am ...
1
vote
0answers
22 views

Howto provide user access to /sys/class/backlight/acpi_video0/brightness programatically (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 ...
0
votes
1answer
46 views

My C program CPU usage goes to 80% when redirecting to /dev/null

I wrote a C program that operates with UDP sockets and the serial port /dev/ttyS1 on uClinux. If I start the program normally as ./program the CPU usage is around 24%. However, if I start the program ...
0
votes
0answers
22 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 ...
2
votes
1answer
57 views

Solaris pstack how to read output / output format

I have the output from a Solaris pstack on a core file. I don't understand how to map the numbers in the log to the parameters that were being used by the functions in question at the time of the ...
0
votes
0answers
15 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 ...
2
votes
2answers
79 views

Why does strace show that syscall =?

I made a system call and recompiled the kernel, however upon running the system call it returned Killed. So, to trace it, I used strace, which shows the following message: syscall_0x224(0x7ffda7199738,...
1
vote
0answers
24 views

Where is getrusage defined? [duplicate]

I've been looking into the getrusage function, which I see a prototype for within the file /include/linux/resource.h. I've tried to trace the directives to find where the actual function is, but I ...
3
votes
1answer
57 views

How to set ntpd server time without referencing another server?

I have an embedded system which synchronizes UTC locally using NTP. One of the clients in the system acts as time reference for the other clients. I guess you could think of it as stratum 0. A program ...
0
votes
0answers
23 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
1answer
44 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 ...
1
vote
0answers
32 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
57 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
86 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
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 ...
1
vote
0answers
57 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 ...
0
votes
4answers
136 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
14 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
252 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
37 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
96 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
33 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
111 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
40 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
101 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
64 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
89 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; }
0
votes
1answer
56 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
485 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
38 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
70 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
45 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
59 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
38 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
68 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
59 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
73 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
38 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/...