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
41 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
16 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 ...
1
vote
1answer
1k views

How to determine which Berkeley DB version is used for RPM's database?

I am attempting to read and write the RPM database located in /var/lib/rpm under CentOS 5, and eventually other system types (CentOS 6, RHEL, etc.) The problem is that I don't know what version of ...
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 ...
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 ...
2
votes
1answer
51 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 ...
2
votes
2answers
71 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,...
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 ...
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 ...
0
votes
0answers
40 views

How to make system() function unblocking? [migrated]

I am calling an executable from another executable in android Linux. Following is the relevant code: ... int status = system("/system/bin/executable"); ... My requirement is not to wait for the ...
3
votes
1answer
55 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
1answer
2k views

Custom priority value: is a pthread high sched prio positive or negative?

I’m trying to reimplement in a backward-compatible way the RobotC API from C (although some details would better fit or would be easier with C++), and trying to reimplement their multithreading API in ...
0
votes
4answers
134 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
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
1answer
41 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
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. ...
-1
votes
1answer
43 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
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
31 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:...
5
votes
2answers
1k views

How to programmatically retrieve the GID of a running process

I need to write some C code to check the effective GID of a running process whose PID I know. I've not found any direct way to do this. There are a number of heavyweight kludges I could use, such as ...
4
votes
1answer
11k views

Changing a user's default shell

I have created a simple C shell on my local Linux server. I am trying to learn how to change the default shell of another user (bob) to be this new C shell that I have created. Is it possible to ...
2
votes
1answer
142 views

How is the C library able to access environment variables?

How do functions like getenv(3) access the environment when my program doesn't have any references to the environment?
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
52 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 ...
3
votes
2answers
998 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 ...
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
216 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
36 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
91 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 + ...
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 ...
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
70 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). ...
1
vote
1answer
78 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
168 views

How to supply a command to 'stdin' of a running process from a second shell?

If you have a process that is waiting for user-input from the stdin scope, then how can you supply that user-input from a second terminal ? Specifically, if I run the c-program while(1){ fgets(...
0
votes
0answers
27 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 ...
0
votes
1answer
45 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
87 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
74 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 ...
5
votes
1answer
818 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(...
2
votes
0answers
735 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 ...
0
votes
1answer
565 views

Serial Port Stream / Bash or C Script

I have a serial device (speed radar) that outputs data every 250ms. Here is the info I have on the device: 1. Speed Packet Protocol The Radar message packet consists of 7 bytes @ 1200 baud, no ...
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
0
votes
1answer
2k views

Having trouble executing a compiled C program

I am running an Ubuntu v10.04 through VirtualBox. To test the persistence of files I create in the virtual machine, I wrote a very basic C program. When I shutdown the virtual machine and restart it, ...
3
votes
1answer
406 views

I want to participate in linux kernel development, where can i find some what is needed to do? [closed]

I want to participate in linux kernel development but i don't have idea what, in technically meaning i can do (i am looking for tasks). I am experienced C programmer, i know some linux kernel, i have ...
6
votes
1answer
452 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
37 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 ...
0
votes
2answers
55 views

Text from standard input not visible after program exits from a readline

I am facing an issue where the text from my stdin is not visible from on my terminal. My program does the following Sets a SIGALRM handler which exits a program when there is no input from the user ...
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 ...