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

c/c++ main source calling a function/library dynamically need its header? [closed]

Does c/c++ main/caller source calling a function/library dynamically still need its declaration header like that of done statically ?
0
votes
0answers
19 views

How to create a file based on the blocks

Recently I'm using nvme-cli to write the data to the block devices, the nvme write and read will allow the user to write to specific blocks. Unfortunately, they don't offer a write or read interface ...
0
votes
0answers
45 views

Trying to compile a simple OpenGL application and it fails with no clear explanation

I am new to OpenGL and the various libraries that makes your life easier programing with it. I tried making my first simple application on my GNU/Linux Debian with Clang (clang++) and it fails at ...
0
votes
0answers
22 views

Custom PAM fails at PAM_CONVERSATION in ssh

I've been trying to implement a custom PAM for 2nd Factor Verification. The Custom PAM needs to read factor selected(integer) and pass it on to the program. The below code works fine in SUDO and SU ...
-2
votes
1answer
42 views

make: *** No rule to make target … Stop

I failed to compile the below software but ran into an error. wget -c https://sourceforge.net/projects/r8s/files/r8s1.81.tar.gz tar xvfz r8s1.81.tar.gz cd r8s1.81/src make -f Makefile.linux ...
0
votes
1answer
17 views

How does “latent_entropy” modify linux kernel functions?

So in the linux kernel, we have the following function's method signature in /kernel/fork.c: static __latent_entropy struct task_struct *copy_process( struct pid *pid, ...
0
votes
1answer
55 views

How to get actual client IP using C in linux systems instead of localhost address

I am trying to read IP address in ubuntu system using C code #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include &...
0
votes
1answer
36 views

Why MYVAR=something wont appear in printenv? Is this related to getenv function?

Im trying to understand why getenv from stlib.h returns non null for PATH but not for my custom defined variables like ANDROID_PRODUCT_OUT. I think it has something to do with this: ...
0
votes
0answers
56 views

How to read() from Bluez AcquireNotify file descriptor?

I am attempting to write a Bluetooth client application for Linux which subscribes to a service from a paired Bluetooth device. I am considering the use of file descriptors here in order to test ...
0
votes
0answers
27 views

tcgetattr Error (input/output) c

Hi working on a project where am making a communication through serial port ! When am trying to open /dev/ttyS0 or any other despite that the file is opening right am getting a tcgetattr arror when i ...
0
votes
2answers
24 views

How to access an inetd service?

So I created a simple inetd error logging service according to this example https://en.wikipedia.org/wiki/Inetd #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { ...
0
votes
2answers
92 views

Where are the files related to the stack on a Unix OS?

I am running Arch Linux, 64bit latest update on one of my computers. I am currently a Computer Science student and we had a test yesterday where we were to implement a dynamic stack using linked lists....
0
votes
2answers
57 views

Locating the C header “stdio.h”

I wrote my first C program which is the generic "hello world" program. Could anyone please tell me where can I find stdio.h file in my system? It will help me a lot in understanding of the ...
1
vote
0answers
11 views

Build against an old glibc with Guix [migrated]

Say that you got a c program, but almost any program will do, and put it in a file: #include <stdio.h> #include <gnu/libc-version.h> int main (void) { puts (gnu_get_libc_version ()); ...
-1
votes
0answers
22 views

Why I can't read from and write to socket with printf and scanf? [migrated]

I wonder why this code is not working. I mean: When both the server and client are running I can type and type with no result. However, when I kill the client, the server starts outputting everything ...
0
votes
0answers
13 views

Timer disarms when interval is too small

Timers seem to disarm after process is resumed (SIGCONT) ONLY when interval is too small. I use timer_create with CLOCK_REALTIME. My linux distribution is ubuntu 20.04.1 This is the code that shows ...
2
votes
2answers
37 views

How do I build PKGCONF and LIBFFI and subsequently Python3.9 with ctypes support without sudo and write access to /usr/local?

The Question(s) How do I properly configure pkgconf and libffi to allow the python3 build process to correctly use my libffi version at every step of the build process, in order to import the _ctypes ...
1
vote
1answer
42 views

Unexpected access rights of a file

I'm using linux as a subsystem in windows . I do have a problem when creating a file via bash terminal . If I run the command touch foo.txt then ls -l foo.txt. All the access rights will be activated ...
0
votes
0answers
38 views

ifort will not find gmp library (libgmp) while linking

Does anybody know the underlying sorcery behind libgmp?? I am working on compiling a program (hires_ifr.c) on Red Hat Enterprise Linux 7.9 that previously had no issues. It is now failing to find the ...
1
vote
1answer
62 views

How do I run shellcode on Linux kernel 5.8+?

The assembly code I'm trying to run is simply a syscall 60. # exit.s .intel_syntax noprefix .section .text .globl _start _start: xor rax, rax mov al, 0x3c xor rdi, rdi xor rdi, 1 syscall ...
2
votes
0answers
40 views

Cannot open file with absolute path in Systemd Service

I have a .service which running my C++ application. My path is absolute path. It works when it is launch via command line but fails to open file when lauch via a systemd service. Output in service is ...
0
votes
1answer
27 views

Why open() system call does not open swapfile in Ubuntu?

I have a question about open() system call. I am writing a C code, in which I need to open all files from a provided directory in read only mode. Before the open call I check if the user has read ...
0
votes
1answer
20 views

Trouble Starting up a Daemon written in C with systemctl

I am trying to register my daemon program that I wrote with C with systemd. I use the following script, [Unit] Description=App After=network-target [Service] Type=simple ExecStart=/usr/local/bin/...
0
votes
1answer
67 views

How can I redirect the STDOUT to STDIN in a C program

Lets say I want to write a C program that executes the same command as : ls -l | wc -l The following is an attempt : int main(){ int fd; char *buffer[] = {"ls", "-l", (...
0
votes
1answer
22 views

How does many binaries changes the percent number of the execution in its right place?

I'm trying to write a C program which can do the thing that many binaries such as package managers do in execution time. They change and add to the already outputted texts in terminal and it makes it ...
0
votes
0answers
9 views

Activate multiple clients on rpc middleware

I made an rpc middleware using c. and I couldn't figure out how to activate multiple clients on the same server. I normally just type ./assign_server on one cmd window(assign is the name of the ...
0
votes
1answer
22 views

Problem in gaining uid of the system caller in a system call LKM using cred.h

I was trying to get the uid of the process runner which is calling my syscall. I use linux/cred.h and its macro called current_uid() . The problem is that it returns a type which is unknown for me, ...
0
votes
0answers
28 views

uaccess.h header file error in function set_fs in LKM compiling process

I was trying to compile my Linux Kernel Module and in compiling process with gcc, I got this error: ./arch/x86/include/asm/uaccess.h: In function ‘set_fs’: ./arch/x86/include/asm/uaccess.h:32:29: ...
0
votes
0answers
53 views

Interpret bash escape sequences and other characters using ncurses

I want to design a terminal multiplexer like tmux, but not that complex, something minimal, that works remote, using ncurses. On the server side, the workflow is as follows: The server process ...
0
votes
1answer
17 views

Loadable Kernel Module logging problem in insmoding process

I'm a beginner in LKM programming. I was writing a simple argument passable module which gains command line arguments and then logs them in alert level. The problem is that I don't know why it doesn't ...
0
votes
0answers
14 views

How to terminate a process scheduled with SCHED_DEADLINE if it meets its deadline?

I created a process scheduled with SCHED_DEADLINE mode as follow : attr.sched_policy = SCHED_DEADLINE; attr.sched_runtime = US_TO_NS(monitor_params.normal_wcet_us); attr.sched_period = US_TO_NS(...
0
votes
1answer
30 views

How to get the task_struct of a pid?

I would like to get the task_struct of a process by his PID because I need the timing fields for a monitoring application. Is that possible without creating a module ? If not, is there a way to get ...
1
vote
0answers
173 views

BadAccess (attempt to access private resource denied) when running Berry

When I run the berry window manager from the CLI I receive the following error. X Error of failed request: BadAccess (attempt to access private resource denied) Major opcode of failed request: 2 (...
0
votes
1answer
59 views

How to replace Shuf with rand (from C++) with a seed of time in order to make my script more random [closed]

I have this script that extracts 200 random characters from a set: tail -n+2 file.fasta | tr -d '\n' > newfile n=$(stat -c "%s" newfile) r=$(shuf -i1-"$((n-200+1))" -n1) newfile ...
0
votes
2answers
80 views

How to call particular function in a C source file from a shell script?

I have a C source file with some functions in it. I want to call some particular function from a shell script. I have a sample.c file with the below content. I want to call funcA here from a shell ...
1
vote
0answers
35 views

Dynamic Linking when Migrating C++ Program from Solaris to Linux

The Problem I'm attempting to migrate a legacy application's build process from an older Solaris machine to Linux, specifically, RHEL 7.7. The application was originally built using Solaris Studio (...
0
votes
0answers
89 views

gcc makefile error: “No rule to make target …”

I'm trying to use GCC (Linux 64 bit) with a makefile to compile my project which is a driver. I am trying to mix assembly with my c project, cpu_check and entry are c files while cpuid_available is an ...
0
votes
1answer
12 views

Are separate blocking-IO accesses to a file consistent at runtime without explicit syncing in Linux

I'm trying to figure out how often a sync or fsync operation really needs to be run in scenarios where power loss of concurrency isn't really a concern. I'm looking for any guarantee the Linux kernel ...
0
votes
1answer
27 views

How are conflicts avoided in Linux Headers?

I'm trying to understand how Linux works and how to build modules. So far I saw that Linux headers are stored in /usr/include and that the compiled implementation of these interfaces are located in /...
0
votes
0answers
87 views

gdb file not in executable format

gdb given an error "/home//bin/exe": not in executable format: File format not recognized gdb -p 28532 --args command1, command2 GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-120.el7 ...
0
votes
0answers
32 views

Compiling C on Manjaro

First of all, I'm pretty new to the whole Linux world so sorry if this question may seem stupid. I'm currently studying informatics and telecommunications, I tried Linux for the first time about 2 ...
1
vote
1answer
23 views

How pass the file's content through Named Pipe and then copy it into another one?

I wrote 2 programs that normally 1.create the named pipe(server) and 2. pass the string from the shell to the server part. I understand how to hand over a string from the terminal to the server part ...
0
votes
0answers
55 views

Program execution hanging when trying to use fgetc() over a file stream returned by fdopen() function

I'm making a program where I'm creating 3 sets of fifos (named pipes) to comunicate over processes, I have found where the execution is hanging but not why, and now I'm stuck. I have identified that ...
0
votes
0answers
24 views

GNU nano: C syntax highlighting changes if file has 'conf' in its name

GNU nano: C syntax highlighting changes if file has conf in its name: Very unexpected behavior. Why and how to solve (i.e. keep C syntax highlighting if file has conf in its name)? Note: nano is ...
1
vote
1answer
52 views

Cannot install 'stringi' R package — C compiler problem?

> install.packages("stringi") [...] * installing *source* package ‘stringi’ ... ** package ‘stringi’ successfully unpacked and MD5 sums checked ** using staged installation checking for ...
2
votes
1answer
60 views

Did fwrite/fread(3) offer different “multiple items” behavior on different platforms historically?

The fread(3) and fwrite(3) have an extra parameter for a variable number of items. So a typical write often has a hardcoded count when all it has is a char buffer to begin with e.g. fwrite(data, len, ...
0
votes
0answers
13 views

compiling the nstat utility in Linux so that debugging information is available for Valgrind

I'm kind of new to picking up C and I want to know if there's a way that I can compile the nstat utility in Linux so that there's debugging information that can be used with Valgrind?
1
vote
1answer
112 views

What happens when two processes listen on the same Berkeley/Unix [file] socket?

What happens when I set up two processes to listen to the same Berkeley socket? Do messages get routed to both? Neither? One of the two? If so, how? Concretely, I can start two gunicorn processes with ...
0
votes
2answers
73 views

Compiling 2 c files into one program and permission is denied

My mission is to complile 2 c files into one executable program. The purpose of this program is when called from within the terminal followed by 2 numbers the output should display the sum of these 2 ...
0
votes
1answer
52 views

Understanding command line arguments in custom shell and the effect of using quote

I am creating a custom shell using C language and I am successful with parsing, fork and exec, pipes, redirection etc. I noticed one particular type of command which seems to be throwing my shell off. ...

1
2 3 4 5
15