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
19 views

Xlib: Why am I having to close the display for mapping and unmapping windows?

// ... int main(int argc, char *argv[]) { int rev; Window win; Display *dis = XOpenDisplay(NULL); XGetInputFocus(dis, &win, &rev); XUnmapWindow(dis, win); XCloseDisplay(dis); /...
0
votes
0answers
27 views

execute mpi c program in linux

Nice people I get this error (I want to execute my MPI program) mpicc file.c -o obj /usr/bin/ld: /tmp/ccuTJy8E.o: reference to the undefined symbol "sqrt@@GLIBC_2.2.5" //lib/x86_64-linux-gnu/...
-1
votes
1answer
30 views

How to add 2 column values and find out percentage value?

When I do df, I get folowing results: Filesystem 1K-blocks Used Available Use% Mounted on udev 1529860 4 1529856 1% /dev tmpfs 308116 960 307156 1% ...
1
vote
0answers
20 views

Cannot read strings properly from GPS [closed]

I want to read only GPRMC but i can't read properly. here is the code. #include<stdio.h> #include<fcntl.h> #include<unistd.h> #include<termios.h> #include<string.h> char *...
0
votes
0answers
26 views

Flex - Any example implementation of GNU Split in Flex? [closed]

I seen many example implementation of existing tools (wc, cat, etc) made in Flex (the lexical analyzer) though simplified, but i yearned for a simple example or/and implementation of the GNU Split ...
0
votes
0answers
22 views

Latency in I2C communication Linux

I am trying to interface an IMU(BNO080) with Jetson Nano board(ARM cortex A57)(Linux 4.9) over I2C(at 400kHz clock). Communication goes well when setting up the configurations and getting the receipts ...
2
votes
2answers
628 views

How does piping affect stdin?

I want to write a C program, and I need to parse stdin. If I type cat file.txt | grep -v match, how does stdout from cat resolve with -v match? Are they concatenated? Are they two different strings? I ...
1
vote
1answer
78 views

How can we perform an arithmetic operation on a register using GDB? [closed]

I want to inject a bit-flip fault into a running program. For this purpose, I'm using gdb to insert a breakpoint into the target program and then flipping a single bit in a random-selected register. ...
0
votes
0answers
89 views

How to change clang-10, llvm-10, etc to clang, llvm, etc.?

I use Spacemacs, and installed llvm-10, clnag-10, clangd-10, and all related packages, in Debian 10. Used the following command to install llvm $ sudo bash -c "$(wget -O - https://apt.llvm.org/...
1
vote
1answer
32 views

How to handle read and write simultaneously in case of ttyUSB in linux C

I want to write application to interface with micro-controller with Linux PC through serial communication. I am able to write the read and write using basic C code using open, read and write function ...
0
votes
1answer
63 views

How to install libpq-dev on fedora?

I'm trying to install libpq-dev on fedora using the command below: sudo dnf install libpq-dev but the result is: No match for argument: libpq-dev Error: Unable to find a match: libpq-dev
0
votes
0answers
72 views

Undefined symbol when executing compiled binary, although readelf shows the symbol with the right version

I have compiled the vagrant-libvirt plugin following the instructions here: https://github.com/hashicorp/vagrant/issues/7039#issuecomment-488499883 It compiles fine, but at runtime I get the following ...
0
votes
0answers
22 views

Catch signal when a command fails

I'm trying to build a shell that gives you suggestions if you have a typing error, but I'm having trouble to catch the error. The user will type something and after parsing it, I will use the execvp() ...
0
votes
1answer
30 views

Buildroot compile error, librt.so: undefined reference to

I'm trying to compile a Buildroot image using a preconfigured builtin _defconfig file... More specific the riscv64_xwin_defconfig which is a simple setup for a riscv64 image with Xorg builtin. Since ...
1
vote
0answers
27 views

posix_spawn and sharing filedescriptors

I'm toying around with a side project where I want to have multiple processes share the same listening socket. In the linux documentation I read that posix_spawn will retain the filedescriptors so it ...
0
votes
1answer
109 views

Setting up DWM (Tiling Window Manager)

im trying to setup DWM, im able to successfully patch few patches, but there a couple things im not able figure out im using this on a laptop so i want to bind my volume, brightness, play pause keys ...
0
votes
0answers
29 views

missing SIGINT from script?

I am experiencing very strange behaviour when I attempt to send SIGINT from a bash script: #!/bin/bash ./executable 6 & PID=$! sleep 2 kill -s SIGINT $PID sleep 2 if wait $PID; then echo "...
1
vote
1answer
58 views

NCURSES SW runs in lxterminal, but doesn't run in a native Linux terminal [closed]

I wrote a "complex" C program using the ncurses library. It "correctly" runs in a lxterminal or gnome-terminal session; but doesn't run in a "native Linux terminal" session without X started (obtained ...
0
votes
0answers
18 views

Ceph RBD kernel module

Within ceph kernel client, I am looking for functions responsible for rbd block open/read/write operations. Since /drivers/block/rbd.c contains function rbd_open(), it looked as a suitable candidate ...
0
votes
0answers
19 views

Undefined reference to SDL functions in c for Conways Game of Life

I'm writing GameOfLife game in c with SDL2 but while compiling the files with CMake, it appears as an undefined reference to SDL functions: What can be the problem and how can I fix it? my ...
-1
votes
1answer
53 views

I just tried writting system() function using fork() and exec(). Is it a better method? [closed]

#include<stdio.h> #include<string.h> #include<unistd.h> #include<sys/types.h> #include<sys/wait.h> #include<error.h> #define size 30 char *get_command(int argc, ...
0
votes
1answer
34 views

Can UDP multicast listening socket receive unicast packet, OR, can UDP unicast socket receive multicast packet, on Linux IPv4 stack?

My understanding is this, if a socket does not bind local address(or binds to INADDR_ANY), and does not call connect() to set remote address/port, then there is no way to prevent unicast packets to be ...
1
vote
1answer
26 views

How can I use fork to calculate partial results of a calculation?

The task that has been given to me is that I have to find all numbers that divide a number (let's call it x) and find out how many times does it divide it. I have to use fork to do the task. What I ...
0
votes
0answers
16 views

Verifying a self signed openssl signature

I have a self signed openssl certificate on my embedded device, only this embeded device has access to the private key which signed the certificate and the certificate is as follows : Certificate: ...
0
votes
0answers
8 views

Using POPEN to find executable file with a given command (Client - server)

The client sends an UNIX command to the server, the command is read from an input.dat file. The server has to examine the paths stored in the $PATH variable, and sends back to the client those paths, ...
0
votes
2answers
28 views

How to execute recursively a program on every files contained in directory with find

I wrote an executable that I want to execute on all the files contained in a directory. This is what the program looks like: #include <stdio.h> #include <stdlib.h> #include <sys/types....
0
votes
1answer
82 views

Can't find the source of some “asm”, “generated” header files in linux kernel?

So, I am writing a module, that is working in kernel space. My code compiles correctly and works correctly. The thing is that there are some header files, which I couldn't find anywhere. That doesn't ...
0
votes
1answer
28 views

File descriptors of executable binary file and shared libraries in /proc/PID/fd?

Do user processes keep a file descriptor for the executable file itself, and for shared libraries? For example, if I look into /proc/PID/fd of bash, I expected to see at least the following fds, ...
1
vote
0answers
50 views

ps command output, WCHAN column '-' for all processes

ps axo ppid,pid,stat,wchan,cmd outputs - for the WCHAN column for all processes, including the ones in sleep, on Debian bullseye, did I do something wrong? BTW, wchan shows 'the kernel function in ...
1
vote
1answer
21 views

Recurrent output of printf() to stdout each time fork() is invoked allthough printf() is invoked prior to fork(). And why does '\n' fixes this? [duplicate]

While I was playing around with fork() I noticed a rather strange behavior but I couldn't figure out myself why this happens. In the example below, each time fork() is invoked the output from the ...
1
vote
1answer
38 views

Are there any alternatives to ltrace that does the same job?

ltrace doesn't work on binaries linked with the -z now option—Check this question—which is the default on my Ubuntu 19.10 system. It only works on binaries linked with -z lazy. Is there any ...
0
votes
0answers
26 views

Understanding Address Family Protocol Specification

NOTE:: Please note this is just me trying to understand unix/linux in detail. thanks Just started reading Beej's Guide to Network Programming Using Internet Sockets, then i came across this section. ...
0
votes
0answers
32 views

Posix UART code for RPI

I am currently working on a project where I am trying to set up UART communication between a PSoC 5LP and a RPI Z W where I am using the UART pins located at the GPIO pins on both devices. Furthermore,...
0
votes
1answer
70 views

Why does grep return SIGPIPE (signal 13) here?

I have to create a program where i have P0 as parent process and P1,...,PN children processes. Every child has to perform grep in a file and return the output in a pipe. Then P0 has to read the ...
0
votes
1answer
30 views

How to set compiler specific standard headers #include paths?

What is a smart way to tell two compilers to look for their #include headers? Running on a standard Linux 86x64 system, my standard compiler is gcc (currently v9.3). Now I'd like to compile some ...
3
votes
2answers
92 views

Capability inheritable for system() call in C/C++

Currently I'm trying to understand capabilities in Linux by reading http://man7.org/linux/man-pages/man7/capabilities.7.html I created a small C++ application with the capability CAP_DAC_READ_SEARCH+...
1
vote
1answer
105 views

How are terminal information (such as window size) sent to a Linux program?

All I know is that a process has file descriptor 0/1 set to stdin/stdout by default. But how does programs such as vi know about window size, especially when I can resize the window freely in desktop ...
0
votes
0answers
52 views

After using `cat` on a binary file, why are letters and numbers left over? [duplicate]

This appears to be an easy concept, but I'm having difficulty finding out what is going on via Google: I have a binary file generated by a C program, example_binary. After using cat example_binary, ...
0
votes
1answer
49 views

Reading and writing from/to ttyS0

I have a Raspberry PI Zero W connected to my virtual machine through USB, which can be found under /dev/ttyS0 on both PC and the RPI. Currently I am trying to send something from the RPI through the ...
0
votes
1answer
26 views

Problems with pthread scheduling and output

I am having some problems with outputing my threads in a right order. My program needs to take at least 2 parameters (could be more, but always 2 at a time because one is integer(how many second does ...
0
votes
1answer
31 views

Kernel module logging using sysfs

How can I log my kernel module (let's call him "test") work process to read by typing cat /sys/module/test/stat/volumes? Which way should I go? Have I use something from kobject functionality or it's ...
0
votes
0answers
7 views

Issue running usbmuxd from an application

I am facing an issue while trying to run usbmuxd daemon in my embedded device. When I run usbmuxd from the serial console, It is running without any issues. However, if I try runnung it from an ...
0
votes
0answers
35 views

“Call” a specific function from device driver's C code

If I had written code in C for a device driver that could control the GPIO pins on a RPI (has Linux Poky installed on it), how would I be able to actually call a function from my C code such as ...
1
vote
4answers
211 views

Reading from stderr in c

This is my c program read from stderr i write #include <uninstd.h> #include <stdio.h> int main(void) { char buff[3]; read(2, buff, sizeof(buff)); printf("%s", buff"); return 0; } My ...
0
votes
0answers
22 views

LIFNAMSIZ undeclared, even though net/if.h included

I am trying to compile the following source on CentOS (taken from here): #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include <unistd.h>...
2
votes
1answer
160 views

How to interact with a terminfo database in C without ncurses?

I've been trying to find information for a few days now. To be clear my goal is to create an ncurses-like C library. I'm fully aware of ANSI escape sequence and how to use them. However I want ...
1
vote
1answer
218 views

Trouble installing libc-dev

I am getting this error when I try to compile a C program on Ubuntu: $ gcc aa.c aa.c:1:9: fatal error: stdio.h: No such file or directory #include<stdio.h> ^-------- compilation ...
0
votes
1answer
71 views

Get current screen dimensions via Xlib using C

Is there any way to get screen dimensions of a display via Xlib using C? I've tried referring to the X.org docs (https://tronche.com/gui/x/xlib/display/screen-information.html), and it only gives me ...
0
votes
2answers
37 views

How to query fqdn of myself under POSIX 2018

Issue 7 of posix removed gethostbyname, so I can no longer do gethostbyname("my_hostname") to get canonical hostname for my machine. I've tried to use getnameinfo instead, but given /etc/hosts like ...
0
votes
1answer
31 views

Issues with RPM Package Creation on Red Hat Enterprise Linux

I am trying to create an RPM package with some basic C and C++ example files before I try doing the package creation with software at my job that is running on Red Hat Enterprise Linux 6, but having ...

1
2 3 4 5
13