All Questions

Tagged with
Filter by
Sorted by
Tagged with
0
votes
0answers
14 views

Error while using JNI: error while loading shared libraries: libjvm.so: cannot open shared object file: No such file or directory

I would like to call Java methods using C program. I've used this tutorial to do that. Unfortunately I have been surprised by an error: ./base: error while loading shared libraries: libjvm.so: cannot ...
0
votes
1answer
27 views

How to kill Linux Kernel Thread?

I am developing Linux kernel module. This module is communicating with my user-space C application. In this module, I am creating a thread. this is a part of my module where I am facing the problem : ...
1
vote
1answer
27 views

How to start systemctl service in Ubuntu 16.10 with simple Daemon C code

I write simple C code #include<stdio.h> #include<sys/types.h> #include<stdlib.h> #include<unistd.h> #include <sys/stat.h> int main(){ pid_t pid; pid=...
0
votes
0answers
28 views

Disk I/O operation CPU affinity

Can anyone help me find on which core a disk I/O operation will execute? The file write application is running on core 11 . Kernel threads affinity is configured to 0-1, IRQ affinity is set to 0-1, ...
0
votes
0answers
35 views

ioctl bug returning -1 EINVAL in SPI transfer function

Not sure if this is C related or something to do with the linux kernel. I'm using an SPI library for Beaglebone called BlackLib, and it has an SPI transfer function. For some reason it wouldn't work ...
0
votes
0answers
20 views

Reading keyboard input in kernel thread polling

I wrote a simple kernel module to read a single character from the keyboard and it worked. #include <linux/kernel.h> #include <linux/module.h> #include <linux/ioport.h> #include <...
0
votes
0answers
36 views

How can I sort binary file entries without using an array in C?

I am writing a program for a university project in Linux. The program lets a user write name entries to a blank file.There is another binary file that has integers that show how many characters have ...
1
vote
1answer
34 views

Why stat(2) on location /proc/<pid>/<files> always give a empty size

It seems that I can't cast stat(2) or fstat(2) on the (pseudo-)file under /proc to get it size. file: test.c #include <unistd.h> #include <sys/stat.h> #include <stdio.h> int main(...
0
votes
2answers
37 views

Allocate the resource of some threads to a global resource such that there is no concurrency(using only mutexes)

The summary of the problem is the following: Given a global resource of size N and M threads with their resource size of Xi (i=1,M) , syncronize the threads such that a thread is allocated,it does its ...
2
votes
1answer
45 views

Why using dup(1) before close(1), open(“/dev/stdout”, O_WRONLY) results in “No such file”?

Problem is same as the title, the OS is linux. I've tried a few examples. dup(1); close(1); int fd = open("/dev/stdout", O_WRONLY); This caused a "/dev/stdout No such file" error. I thought a file ...
5
votes
1answer
40 views

Why is STDIN not propagated to child process of different process group?

Below is the source of a program that executes cat: #include <signal.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> int main() { pid_t pid = fork(); if (!...
1
vote
0answers
40 views

Use chdir to change current working directory

I'm creating a program wich is like an "shell interpreter" but in C, in the main program called "Bash" if i write in command line "change NAME" it creates a fork and executes an execlp to call a ...
0
votes
0answers
35 views

RedPitaya: No data in UART - can't read buffer

I am trying to read out a Sensor on a RedPitaya (running Ubuntu). The sensor (RM08 rotary encoder by RLS) works with the SSI protocol. I connected the Clock wire to a Digital Output Pin and the Data ...
1
vote
0answers
33 views

what is the signal sent by OS when date and time change happens in linux [duplicate]

I have written an application program and what to get notified in this application if system date or time changed, the same way if user presses ctrl+c then OS sends sigkill signal. My requirement is ...
0
votes
2answers
80 views

how can i modify the threads to print “ hello world again” ? in C

how can I force the three threads to print " hello world again" using lock_mutex or sleep function ? im done with it ... /* t2.c synchronize threads through mutex and conditional variable ...
0
votes
0answers
44 views

how to destroy a detached shared memory immediately

I created a shared memory with key 1234 using shmget() and terminated that process. next time when I run that same program, I want to create another shared memory with the same key 1234, But when I ...
3
votes
1answer
65 views

Nanoseconds since midnight

I have a timestamp representing nanoseconds since midnight. I would like to calculate the number of nanoseconds (right now) since midnight, to subtract the two timestamps and measure the latency. I ...
3
votes
1answer
39 views

How to create files which share an extent?

The Linux programmer's manual manpage fallocate(2) states: If the FALLOC_FL_UNSHARE flag is specified in mode, shared file data extents will be made private to the file to guarantee that a ...
1
vote
1answer
25 views

gdb: cascaded signal. info on outer one - HOWTO

Following program generates SIGSEGV from within SIGUSR1 signal handler. #include <signal.h> #include <unistd.h> #include <iostream> void sigusr_handler(int sig_number) { std::...
1
vote
2answers
51 views

Why is the read_pci_config_16 function performing bitwise and when calling inb/inw

To read PCI Configuration space, i need to write BDF and offset to 0xCF8h and then read the data register 0xCFCh I am looking into linux kernel source, where the below logic is used. In file arch/...
-1
votes
0answers
41 views

Example of io mapped memory on x86 [on hold]

I am understanding Memory Mapped I/O vs Port Mapped I/O in x86 I got lot of examples online on Port Mapped I/O (RTC, Keyboard, Speaker, Timer) etc, but not on Memory Mapped I/O. Can anyone refer me ...
-3
votes
1answer
49 views

Forgotten code for user input in C in Linux Terminal

I've written the code, however I cannot remember how to get the user's input. The command to run the code is ./rle "HHEELLLLO W" but in my code, I don't know how to get the code to read the "...
2
votes
3answers
47 views

Synchronization with child signal and parent matches received signals with the file

EDIT: Thanks for the suggestions given so far. I changed the program and now the parent handles some of the signals, but it looks like it doesn't handle all of them. New code and results are posted ...
4
votes
1answer
24 views

How to reopen stdout if it is closed by the process who called exec

Is it possible to reopen stdout, if it is already closed. For example the below code. #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <fcntl.h> #...
5
votes
2answers
108 views

Faster way to get the total space taken by the directory containing 5 million files in linux

I have a target board running linux which has approximately around 5 million+ files in the directory. (This directory doesn't have any sub directories) If i execute this program it takes several ...
0
votes
0answers
19 views

Exposing an API as multiple named pipe (FIFO) files in C

I'm creating a C application daemon that I want to be able to interact with through named pipes. For example, I write in the shell echo hello > /tmp/appname/interface, and the application reads it ...
1
vote
0answers
44 views

Fork multiple process simultaneously without blocking main thread

This is more of a general question than a coding question and I would appreciate some directions or a general approach. My programming task is to implement a simple job scheduler that will execute ...
0
votes
0answers
28 views

Can a pipe be overwritten?

I'm trying to develop communication among multiple processes, but I'm not sure if I can do it with using only one pipe. Once the pipe is initiated and used like this: int fd[2]; int pid = fork(); ...
2
votes
1answer
52 views

Is it legal to read a file descriptor into NULL?

Recently, I've been fixing the timestep for the sake of a library that I am writing. Following some research, suppose that I ended up with this prototype, precise and easy to combine with the generic ...
0
votes
0answers
20 views

Using exec function with another c file [duplicate]

I'm kind of new to functions fork() and exec and I don't seem to understand how can I use the execv function in order to pass arguments & execute another c file. my main.c file: (in where I call ...
0
votes
1answer
49 views

Multi threading error segmentation fault in C

I am trying to multiply two matrices using multi threading. Here I compile the program using gcc in linux and run by inputting number of threads. gcc multiThread.c -o test -lpthread ./test 4 Here I ...
0
votes
1answer
50 views

linux poll behaviour with infinite timeout

poll function in Linux waits for file descriptor (fd) to become ready. The functions wait for fd to become ready for the minimum time specified in its timeout argument. Check the manual page poll(2) ....
0
votes
0answers
35 views

Why does the pw_passwd field of the struct returned by getpwnam not contain my password hash?

I could not get suckless' slock to work, and the issue came down to getpwnam returning a struct where pw_passwd is set as "x". It does not work regardless of whether the user name given to getpwnam is ...
0
votes
0answers
25 views

What is the issue with my pipe only tee is working?

I am having an issue with piping to a child of a fork. Only tee seems to work. I create a pipe call execvp and do a fork Data is passed to the child through a pipe. It work with tee any thing else ...
2
votes
1answer
79 views

Problem while opening a file in C on linux

I'm having problems with my C program which works perfectly on Windows but not on Linux. I use the following method for reading line by line a file: char * getLineOfAnySize(FILE* fp, size_t ...
2
votes
2answers
91 views

How to test if a shared object is 32-bit or 64-bit?

I'm developing a C++ application where I need to test whether a .SO is 32-bit or 64-bit, before loading it. I managed to make this assessment on Windows, taking the Headers file. Now I'm searching ...
-1
votes
1answer
64 views

How to read a block device till the last byte

I want to read a block device file, block by block until last byte even if the block is full of zeroes. My code is this. size is the no. of bytes I want it to read in one go - could be anything 4K, ...
0
votes
0answers
56 views

UART C code for linux working only sometimes with BASYS3 FPGA

I've got a strange situation with my C code for linux (ubuntu 19.04), I'm an FPGA developer, mainly I know only HDLs languages, now I've decided to focus on C coding, I have very poor background with ...
0
votes
0answers
22 views

How to get pulseaudio volume in C?

I am writing my own status bar program for suckless dwm and the last thing left on the list is getting volume percentage from default pulseaudio sink. In bash, I have solved this with this pipe: ...
-1
votes
1answer
51 views

How to call a function with its arguments from another function?

I am developing Linux Kernel Module. I want to call the module exer_write function : exer_write(struct file *pfile, const char __user *buffer, size_t length, loff_t *offset) from another function ...
0
votes
1answer
32 views

can't call VMXON on more than 1 processor

I'm trying to build my own hypervisor for Linux (5.0.x kernel) on an Intel chip and I'm running into an odd problem. Whenever I try to execute VMXON on more than one processor, it fails. I made sure ...
-1
votes
0answers
28 views

Windows WSL : GDB does not refresh, looks terrible

I am having trouble with using terminal programs with WSL, specifically GDB. It appears that the program does not refresh, so text shows up everywhere, making a mess. I have no idea how to solve this ...
1
vote
2answers
48 views

File transferred as binary via libcurl is corrupted

There are many other threads talking about binary file corruption, yet they all seem unrelated to my problem somehow. I have a C program that downloads/reads files. Because I do not write all the ...
-3
votes
0answers
43 views

How to check a my main.c is running background in LINUX? [duplicate]

I use daemon in my main.c code. I am running my main.c code on Linux and I do not want to get run the same executable file while my main.c's executable file is running. How can I know my main.c's ...
0
votes
1answer
30 views

How to get ciphertext_len from ciphertext to use in openssl EVP_ in c program

In order to find ciphertext_len from ciphertext to use in openssl EVP_ in C program I have created a ciphertext using OpenSSL in bash to give base64 output: echo -n "Hello"|openssl enc -aes-256-cbc -...
2
votes
1answer
48 views

How can we reboot through keyboard port

How is the below code able to reboot the system, can any provide documentation on this #define KEYBOARD_PORT 0x64 ioperm(KEYBOARD_PORT, 0x01, 0x01); outb(0xfe, KEYBOARD_PORT); What is the ...
-1
votes
1answer
20 views

ioperm is working without root permission

I read that we need superuser permission to access I/O ports from user space. But i am saying different behavior. ioperm is successful under normal user. #include <stdio.h> #include <errno.h&...
-1
votes
1answer
33 views

C Sendto doesn't work when doing it repeatedly

I'm facing a weird problem when using sendto() in C. I have this code: struct sockaddr_in currSocket; int currSocketLength = sizeof(currSocket); memset((char *)&currSocket, 0, sizeof(currSocket));...
0
votes
1answer
45 views

sighandler_t typedef statement in Linux? [duplicate]

While studying Signals in Linux, I came across this declaration : typedef void (*sighandler_t)(int); sighandler_t signal (int signo, sighandler_t handler); The handler function must return void and ...
1
vote
0answers
22 views

Multiple HID profile registered with different descriptor

I'm developing a product on a linux system acting as a custom keyboard and can connect via Bluetooth to multiple devices using the BlueZ 5 D-Bus API. So far, I've managed to implement the simultaneous ...