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
0 answers
20 views

Using Terminal with a serial connection

Hello I am using terminal to output my serial connection device. I was wondering how can I get rid of the spaces when it starts a new line. On Windows I would use Putty and turn on Implicit CR in ...
David Duong's user avatar
0 votes
0 answers
22 views

ld.lld: error: cannot find linker script -r

i am trying to compile a kernel but it always return this error: LD arch/arm64/kernel/vdso/built-in.o ld.lld: error: cannot find linker script -r make[2]: *** [scripts/Makefile.build:507: arch/...
xxjoe's user avatar
  • 1
0 votes
0 answers
60 views

Why do_exit() undefined?

I was building a kernel module for trying kthreads. A thread function after doing its works exits by calling do_exit(0). But when I am trying to compile the module, it is showing the error that ...
arka's user avatar
  • 193
0 votes
0 answers
46 views

Memory protection keys: Exception handler crashes if pkey0 is write-disabled

Background: in-process isolation based on memory protection domains in x86/linux using memory protection keys (MPK) and the protection key register PKRU. Setup: The program first executes ...
Robert Kueffner's user avatar
0 votes
1 answer
62 views

gdb print out a pointer is null or not

source:https://git.postgresql.org/cgit/postgresql.git/tree/src/backend/optimizer/plan/planner.c (gdb) n 3556 if (root->group_pathkeys) (gdb) s 3558 else if (root->...
jian's user avatar
  • 539
0 votes
1 answer
24 views

Why does netstat show my socket tutorial program having a port of "x11-1" instead of the port I set in code?

I am trying to learn about socket programming, and I have the following function to set up a socket: 29 int CreatePassiveSock(char *protocol, char *portstr, int qlen) { 30 ...
Anthony De Vellis's user avatar
0 votes
0 answers
21 views

Unable to open a file for writing which has write permisions [duplicate]

There is a regular file file in the /tmp directory with write permissions -rw--w--w- 1 user1 user1 /tmp/file When I try to open this file as a user (I run the code after su user2) who is not the owner ...
ibse's user avatar
  • 247
1 vote
1 answer
56 views

What tells make that a file is an intermediate file (and can be auto removed)?

I'm simply studying make. And I stumble upon the question on make's autoremoving intermediate file. I'd like to better predict how make would mark file intermediate (i.e. answer "Would auto ...
Koala Yeung's user avatar
2 votes
2 answers
56 views

What is the region of memory allocated by malloc()?

I was writing a multi-threaded C program using pthread library. The program calls the malloc() from a thread and the main-thread. When I inspected the memory address returned by malloc(), the address ...
arka's user avatar
  • 193
1 vote
2 answers
75 views

How can pwrite protect against overwriting data?

Assume we have two processes A & B. they both want to append to the same file. both opened the file with open (without O_APPEND) function and they are using pwrite(fd, buf, bytes, offset) to write ...
Myonaiz's user avatar
  • 113
0 votes
1 answer
225 views

Modpost: "module … uses symbol … from namespace …" error porting FL2000_DRM driver to newer version

I'm trying to port https://github.com/kenballus/fl2000_drm_519, designed for linux 5.19, to linux 6.2.11, but after applying the patches attached below, I'm getting this error and I don't know how to ...
alonely0's user avatar
5 votes
1 answer
124 views

Is there a *BSD equivalent of MacOS renameatx_np, atomic swap file renaming?

I am looking to create a *BSD compatible C function like the one below: int fs_ext__swap (const char *from, const char *to) { int res = renameatx_np(AT_FDCWD, from, AT_FDCWD, to, RENAME_SWAP); ...
Lee's user avatar
  • 491
1 vote
0 answers
30 views

PTRACE_PEEKTEXT ptrace: Input/ouput error

I try to read the values from memory with using PTRACE_PEEKDATA. To find the memory address of specific line I am using with objdump - objdump --dwarf=decodedline ./exe_filename and got the output: ...
Aviel15's user avatar
  • 11
0 votes
2 answers
61 views

Program starts from rc.local but doesn't do anything

I have a program which uses msqllib. It scans some hardware that I build and then updates a mysql database. This program has been running for a number of years but I have never been able to autostart ...
Nigel W Johnson's user avatar
0 votes
0 answers
36 views

Virtual keyboard using UHID

I am trying to achieve what the QMK firmware does for keyboards but using software. So, I would like to turn off keys, substitute some keys for others, layers and etc. The first thing that appeared ...
Henrique Hott's user avatar
-2 votes
1 answer
166 views

How to capture sudo command system call output?

I have rather convoluted C code - system call, but it does the job creating the link. When successful the result is output to stdout - I assume... When it fails - the result goes to where ?? I would ...
anne's user avatar
  • 43
0 votes
2 answers
86 views

Measuring execution time of BASH and custom shell

I have written simple shell in C with job control and piping/redirection functionality. How can I compare execution time(real,user and sys) of this shell with BASH ? I tried to measure time of ...
Marko Brodanac's user avatar
1 vote
0 answers
96 views

Linux TCP/IP kernel stack and VFS interaction

I'm reading the Linux kernel implementation of the TCP/IP stack. Everything was ok till I encounter this figure while reading TCP/IP architecture, design and implementation in Linux As you may see ...
ca-hercor's user avatar
1 vote
2 answers
292 views

Why all output of my C program directed to stdout is sent to journald?

I work on yocto based linux distribution. I'm no expert on systemd and neither on systemd-journald. My C program my_c_program is started at boot by the script my_script.sh. Below there is the file ...
frankfalse's user avatar
1 vote
2 answers
96 views

grep -c "string" file.txt if "string" continues on next line?

As the title says, I am trying to count the instances of a string in a text file. However, in some instances, the string continues onto the next line. How can I alter this simple code to find the ...
zaPIRATEne's user avatar
2 votes
2 answers
253 views

Can you compile a file without writing to disk?

I'd like to compile some code from within a C/C++ program. Here's how it would work. I would have a buffer in memory (dynamically allocated) that contains ASCII text that constitutes C code. From my C/...
Isaac D. Cohen's user avatar
0 votes
0 answers
163 views

QEMU CAN Bus Emulation; error on socket bind: No such device

The goal is to run following C program in the VM. int main(int argc, char **argv) { int s, i; int nbytes; struct sockaddr_can addr; struct ifreq ifr; struct can_frame frame; ...
snikers12's user avatar
2 votes
0 answers
53 views

What's the difference between ftrace and blktrace tracepoints?

For instance, we have /sys/kernel/debug/tracing/events/block/block_bio_complete and block_rq_complete which is basically IO completion trace points for ftrace, I believe. Using sudo blktrace -d /dev/...
Ken Y-N's user avatar
  • 253
0 votes
1 answer
66 views

Using IPC_CREAT with an already created shared memory segment

I am trying to figure out what will happen if I use the IPC_CREAT flag with shmget(). I have used a key of an already created shared memory segment from another process. When I did so, the calling ...
John adams's user avatar
1 vote
0 answers
819 views

Compiling CFLAGS in a Yocto Recipe File

Issue: I have 2 macros I added in a c file and I have 2 machines. Using Yocto recipe I wish to build the code with specific macros for specific machines. Breaking down the issue in sub parts - hello.c ...
Nathan's user avatar
  • 21
0 votes
0 answers
83 views

It seems that the systemctl stop does not normally terminate my process

When I enter the systemctl stop command to exit the process and check the status with the systemctl status command, some of the items that need to be printed are not found. For example, if you check ...
monster-dev's user avatar
0 votes
1 answer
96 views

shmget() and shmat()

Using shmget(), we can allocate a shared memory block of certain size in bytes and using shmat(), we attach this shared memory block to the address space of the calling process. I need to check my ...
John adams's user avatar
-4 votes
1 answer
46 views

how can i reduce the byte of the code bellow from 146 to 144 need help please [closed]

How can i reduce the byte(memory) of the code: #include<stdio.h> /** * main - Entry Point * Return: Always 0 (success) */ int main(void) { printf("Size of a char: %d byte(s)\n&...
Aroh chukwuebuka's user avatar
0 votes
1 answer
57 views

Unable to use GTK on Debian, due to having libraries always be missing

Due to my laziness, I have downloaded precompiled binaries for GTK programmes (rather than compiling them which would have been a drag considering how time-wasting it is). EDIT:using sudo apt get, ...
haruhisuzumiya's user avatar
0 votes
2 answers
147 views

exec() system call in Linux

Accoding to this link, we need to terminate the list of argumnets by a null pointer. This is stated as : The list of arguments must be terminated by a null pointer. My question is why we need to ...
John adams's user avatar
0 votes
1 answer
63 views

lighttpd: ajax request prints the content of cgi script instead of running it

I am using lighttpd version 1.4.55 within an ARM environment. I created an HTML pages in which there is a button used to download some json data. This button trigger a submit form that calls a cgi ...
marco's user avatar
  • 1
0 votes
1 answer
44 views

gcc doesn't find output fine and therefore cannot compile my c program (vscode)

As the title suggests it is the output file it cannot find, not sure why this is an issue here is my c_cpp_properties.json: { "configurations": [ { "name": &...
Manfred's user avatar
  • 25
0 votes
1 answer
351 views

Custom network interface with packet send and receive functions in user space

Is it possible to implement a custom network interface in user space on a Linux platform? The netif must transmit packets on an unusual physical link which is best accessed in user space. The send and ...
Larsp's user avatar
  • 33
1 vote
0 answers
72 views

create PAM converstation

I tried to create a simple PAM module, that print some message, wait X second and return the PAM_SUCCESS status. Firstly I tried with this script: #include <security/pam_appl.h> #include <...
Atisom's user avatar
  • 71
0 votes
1 answer
564 views

Including cURL in makefile

I'm using curl in my code and running through Makefile. but while running with "make" command its giving error like "curl/curl.h: No such file or directory". Here below is my ...
nima's user avatar
  • 1
-1 votes
1 answer
70 views

In which format C program should export to run on linux?

In windows we publish application in .exe format, so I have C program and I want to publish that application for linux. In which format I should publish it and how?
Abhishek Borse's user avatar
1 vote
1 answer
57 views

How do unix systems call into an application?

I am currently implementing a C runtime library for the Arm64 platform, and I am unsure which assumptions I can make about the environment at the precise point that the application is executed (what ...
lte678's user avatar
  • 11
1 vote
0 answers
27 views

facing isue in UDP multicasting after changing ip of the device

we have a requirement for UDP multicasting in our project using Linux 4.1 kernel with static ip address. basic UDP multicasting using sendto function to send data is working fine with device static ip ...
Rajesh's user avatar
  • 11
0 votes
0 answers
140 views

How to properly read from a sensor with libiio?

I am trying to read one sample from a sensor using libiio, but for some reason I always get the same sample unless I restart the application. Here is a minimal example #include <stdio.h> #...
neolith's user avatar
  • 213
1 vote
0 answers
79 views

Read the value from a virtual memory address in a program every frame

I've been trying to write a program in C that reads the value of a virtual memory address in a game so I can tell when it's loading. This is pretty easy to do on Windows but I can't seem to find much ...
Loomeh's user avatar
  • 11
-1 votes
1 answer
290 views

How to prevent timeout command to kill?

My process a.out is starting by a timeout command similar to: timeout 1 ./a.out - < file.txt It runs on a server and I have no control over that because it is part of a shell script that being ...
user174174's user avatar
0 votes
0 answers
28 views

How to work with network and hard disk in kernel.c?

I am building a small operating system I'm going to save the information on the hard disk, like creating a txt file on the hard disk And also performing network tasks such as socket or http requests ...
masterc ccc's user avatar
1 vote
0 answers
51 views

Authenticating user groups with PAM in C

I am writing a program that allow certain users and user groups to not require authentication through PAM. I want to use the pam_access module but am fairly new and can't find good documentation for ...
Alex S's user avatar
  • 11
-3 votes
2 answers
266 views

Why this program can not read text file in struct? [closed]

Here is my a.txt file which is of three lines. It does not contain any extra spaces or any non printable characters: David Joans 018976 David12 Here is my code in C to read this file where I have ...
Anup Adhikari's user avatar
0 votes
1 answer
173 views

Why compiling Fortran code with include is different from #include?

I can't understand why including a text file that contains some C lines in a fortran77 code gives me a warning if I do not use #include. I wrote an example of a code that is supposed to read some text ...
Giorgio Maria Cavallazzi's user avatar
0 votes
0 answers
61 views

Writing UEFI variable in kernel module fails with code 2 (EFI_INVALID_PARAMETER)

I'm writing a kernel module that creates/sets a UEFI variable using the linux/efi.h library. Here's my code so far efi_status_t status; efi_char16_t name = L"Teste01"; u32 attr = ...
Allan Almeida's user avatar
0 votes
1 answer
123 views

Where is the HAVE_UNISTD_H macro defined?

#ifdef HAVE_UNISTD_H #include<unistd.h> #else extern int getpid(void) #endif /* HAVE_UNISTD_H */ I guess the idea is to check if header file <unistd.h> is available or not. if not then ...
jian's user avatar
  • 539
2 votes
0 answers
133 views

How to find the memory address of the parameter(s) of a function

For context, I am attempting to exploit a buffer overflow as a practice exercise. I need to pass a parameter into a function via memory address. I have found the address for the function I would like ...
1Poseidon3's user avatar
0 votes
1 answer
89 views

Unexpected behavior of linux specific getline() function in C

#include <stdio.h> #include <stdlib.h> #define MAXLEN 1024 void reverse(FILE *, FILE *); int main(int argc, char ** argv) { ... reverse(fptr, stdout); ... return 0; } void ...
arka's user avatar
  • 193
0 votes
1 answer
131 views

Working of grep in xv6 implementation?

char buf[1024]; void grep(char *pattern, int fd) { int n, m; char *p, *q; m = 0; while((n = read(fd, buf+m, sizeof(buf)-m-1)) > 0){ m += n; buf[m] = '\0'; p = buf; while((...
arka's user avatar
  • 193

1
2 3 4 5
17