Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
15 views

failed using scanf to read from pipe [migrated]

Working on IPC I was asked to write a C program that works as pipe between other two C executables: The first executable named 'sln1.out' receive six arguments and print three numbers. The second ...
0
votes
0answers
23 views

Pipe with multiple child process [migrated]

I want to create N processes from one parent and this child processes have to read that parent write, but what i have only the first process reads correctly: #include <stdio.h> #include <...
0
votes
1answer
41 views

Can we execute the pro-c file which is compiled on UNIX on Debian 9? [closed]

I have a pro-c file which is compiled on UNIX. The script logins to oracle DB and interacts with DB and update some values there in some tables. We are migrating from UNIX to Openshift Container ...
0
votes
1answer
23 views

What is the IP address of my local interface that is required by IP_ADD_MEMBERSHIP?

In this man page http://man7.org/linux/man-pages/man7/ip.7.html, it is written that IP_ADD_MEMBERSHIP can be used to join a multicast group. We need to provide, as input, in particular, the IP ...
1
vote
1answer
17 views

DWM Unicode Support

I'm in the process of creating a nice looking statusbar with DWM and I want to implement unicode symbols with font awesome. Supposedly I can use the Pango patch but its out of date (for version 6.1) ...
2
votes
0answers
14 views

No such process (3) when not connected to a network (AF_ROUTE)

When I am connected to a network, I can send a struct rt_msghdr* to the kernel and receive a corresponding route. However, when I disconnect from the network and try to send the same route message ...
0
votes
0answers
27 views

Turning USB into a terminal

I have a hardware device that connects via USB without creating a specific /dev/something. It does change the time on /dev/ptmx and /dev/char but that's about it. All I know are the VID:PID of the ...
-1
votes
0answers
10 views

C - Installing FreeRDP and hit to make install error: field ‘des3_ctx’ has incomplete type

I was trying to install FreeRDP server using the link : https://github.com/FreeRDP/Remmina/wiki/Compile-on-Ubuntu-16.04 I hit to the below error during make && sudo make install [ 25%] ...
0
votes
1answer
38 views

How to avoid multiple 'libFoo.so' open() calls at application launch? [closed]

I have the next so file in /UNI/System/Libs/libmbedcrypto.so.3 directory. When I launch my application, that use libmbedcrypto.so.3 with strace I see: open("/UNI/System/Libs/tls/v7l/neon/vfp/...
1
vote
3answers
51 views

Strange zombie process responds to signals?

I have a strange situation. I have a c-written program “A” which takes as argument the name of other executables, e.g. “B”, “C”, “D” etc.. The main job of “A” is to fork and start “B”, “C” etc, then ...
0
votes
0answers
25 views

Retrieving the SO_INCOMING_CPU of a UDP Socket?

The socket API provides an SO_INCOMING_CPU option, the details of which are provided in the man page: SO_INCOMING_CPU (gettable since Linux 3.19, settable since Linux 4.4) Sets or gets ...
3
votes
1answer
159 views

Does Bash imitate Locale-Specific Translation from C?

Bash manual mentions that 3.1.2.5 Locale-Specific Translation A double-quoted string preceded by a dollar sign (‘$’) will cause the string to be translated according to the current locale. ...
4
votes
1answer
58 views

Why are there multiple copies of header files in /usr/include?

I've been browsing my /usr/include folder trying to get acquainted with the layout and I've noticed that there are multiple copies of header files (at least by name, I didn't actually diff them to see ...
0
votes
0answers
20 views

What does fork() do exactly? [duplicate]

According to the manual, fork() creates a clone of the program in the given position of the code, but compiling the code below in C gives us "AB\nAB\n". How is this possible if fork() is after the ...
1
vote
1answer
26 views

file lock existence check on remote host

I want to check the existence of file lock on a file in gluster file system. So that I can see from any host that whether file lock is held by any process (remote or local) on file in gluster file ...
0
votes
1answer
63 views

Is it safe to send SIGUSR1 to a program, and why? [closed]

When you send SIGUSR1 signal (say the signal handler has been set in advance) to a program while it is executing sleep(100), the signal is caught correctly but sleep(100) is terminated just after the ...
0
votes
1answer
66 views

GCC Compiler Error Again

I was once again trying to install a compiler onto my SGI Indy computer running Irix version 6.5, and this time, I found a file that has all of the libraries I thought I would have needed. When I ...
1
vote
1answer
24 views

Building shared library which is executable and linkable using Cmake

How to create an executable shared-library using cmake? Something like: libtest.so :: linkable shared library libtest.so :: executable too Note: gcc/g++ options are known to achieve the ...
0
votes
1answer
39 views

Emulating a character device from userspace

We are currently working on building a system for data visualisation for different sensors. To make development of the Linux application possible we would need to emulate the behaviour of the ...
0
votes
0answers
10 views

make multiple files program a busybox applet

Is possible to make a multiple files program , a busybox applet? I read the docs/new-applet-HOWTO.txt but it only explain how to add a single file applet . Do i have to convert the whole desired ...
0
votes
1answer
87 views

How to pass argv arguments to a C program using a file or python script in linux?

I used to be able to pass input to C program by first writing a python script and using pipe to send it to the C program as an input or write the output of python script to a file and just doing r &...
1
vote
0answers
61 views

Compiling module on OpenWRT: make can't find build directory

My setup: OpenWRT 18.06.1 Raspberry Pi 2 B Kernel 4.9.120 Attempting to build a very simple hello world kernel module results in the following error: # make make -C /lib/modules/4.9.120/build M=/...
0
votes
0answers
27 views

Redirecting output of loggings when using <syslog.h>

How can I redirect the message this code writes in /var/log/auth.log to /var/log/test.log #include <syslog.h> int main(int argc, char** argv) { char* cap = "TEST 1"; openlog(cap, ...
0
votes
1answer
44 views

Which Libraries can be called inside a Kernel Module

Looking for a list of libraries which can be called from a custom Kernel Module. I understand that there are restrictions compared to user space and libraries like <stdio.h> and <string.h>...
1
vote
0answers
44 views

Build C executable with env variables via Makefile [closed]

I have huge application written in C and Python. I have a Makefile which helps to build final executable on several platforms. Here's a main part (I can't expose too much because of confidential info):...
1
vote
1answer
58 views

Can a system call with non documented `EINTR` return `EINTR`?

I am writing an small application and I want to make it as portable as possible (Linux, *BSD and possibly other UNIXes). My main issue is the management of EINTR. I read that there are some systems ...
2
votes
0answers
46 views

non-root access to physical blocks occupied by a file

ioctl() and FIBMAP can be used to determine the physical blocks occupied by a file, given logical blocks obtainable via stat(); however, root access is required. Why is root access necessary for ...
1
vote
0answers
193 views

Reserve memory in RAM and in the desired physical position

I'm trying reserved 2GB in RAM, but i like reserved in the start memory, in the 0x00000000 position to 0x80000000, Can I do it? I read in the LDD3 that you can reserver spaces in the memory, but in ...
1
vote
2answers
49 views

nano text file formatter? [closed]

Is there a SIMPLE way to format nano file text? My code is getting pretty messy, so it MAY help to format it.
5
votes
2answers
379 views

Avoid command injection with system() api [closed]

We have a legacy C code used to allow less privileged user to run custom scripts with escalated privilege. This has SUID bit set. This code restricts the PATH env to a specific folder and then uses ...
0
votes
1answer
20 views

How to get Mac OS to remember previous auth. from my executable file

I'm writing a tiny unix executable file that changes my macbook's system time manually. Of course, this requires a password, and so I used the system() function to interface with the terminal and ...
0
votes
2answers
28 views

Ubuntu, using a shell script to loop a C program

I have a C program ./myProgram 1 (where 1 is the argument fixed) in the directory gianni@mylinux:~/myWork/myApplication$ ./myProgram I wish to run this C program 100 times using a loop insted a ...
1
vote
1answer
17 views

Should I free the fstab pointer returned by getfsent?

#include <fstab.h> struct fstab *getfsent(void); http://man7.org/linux/man-pages/man3/getfsent.3.html getfsent reads a line from /etc/fstab file and return a variable of type struct fstab*. ...
2
votes
2answers
91 views

Test question regarding grep

Below is a the test question for a practice LPIC-1 exam I took. The correct answer is A. I'm really dazzled at how this is the case. If it's not too much trouble can someone walk me through how A ...
1
vote
1answer
65 views

How to check the signal handler in Linux

I have read this discussion which discuss about how to check the signal actions of each process: How can I check what signals a process is listening to? However, I want to use C/C++, Python or other ...
1
vote
0answers
70 views

Mutual exclusion between all Linux threads and processes [closed]

I'm trying to write a piece of code that should not been executed simultaneously neither by threads of the same process, nor by different processes. In other words, I need global synchronization ...
2
votes
0answers
106 views

Time measurment in Linux kernel: how are clock_gettime, gettimeofday and getrusage related?

I am trying to understand how time is measured by the Linux kernel. I tried to go through the kernel code, but I miss the big picture to understand the code that I'm reading, even if this article ...
0
votes
1answer
36 views

Processor not seeing changes to POSIX shared memory?

Context: I am using POSIX shared memory to provide a set of processes with a shared memory space. I have used this scheme for some time now in order to share data, and it's working okay. However, I ...
1
vote
1answer
225 views

replacing current shell with execl()

In the following C program: #include <stdio.h> #include <unistd.h> #include <stdlib.h> int main(void){ char *shell = getenv("SHELL"); execl(shell, NULL, NULL); ...
0
votes
1answer
50 views

Finding a man page with a standard C or POSIX type? [duplicate]

Is there a way to find a man page given a Standard-C-type or POSIX-type? Such as man size_t or man uintptr_t. This kind of thing can get confusing because uintptr_t is defined in stdint.h, and size_t ...
-1
votes
1answer
91 views

What Debian/Ubuntu package has the documentation for the standard C headers?

On the back of this question, but Debian/Ubuntu specific that has C-standard library headers like (taken from Wikipedia) assert.h , complex.h , ctype.h , errno.h , fenv.h , float.h , inttypes.h , ...
1
vote
0answers
33 views

Fakeroot on macOS tries to delete system directories

I’m having a problem with fakeroot on macOS. I created a pacman fork. When I’d like to delete a package, pacman tries to delete /usr/ instead of a subdirectory. On Linux, it is working fine, though. ...
-1
votes
1answer
300 views

What does the -O2 option for gcc do? [closed]

What does the -O2 option for gcc do? eg. gcc -O2 file1.c -o file1.o
0
votes
0answers
60 views

Is there C language documentation on Linux? [duplicate]

Is there a package on Debian or some other Linux media that provides documentation for the C language? I mean in particular man pages. Eg. so that I can check docs for typedef or other basics (and ...
1
vote
2answers
119 views

Redirecting a string to current TTY

I have some code: char *tty_name = ttyname(STDIN_FILENO); char command[255] = "/usr/sbin/writevt -t "; strcpy(stpcpy(command + 21, tty_name), " -T ' \r'"); system(command); It writes a "space" and a ...
1
vote
1answer
43 views

behavior of interrupt signal after forking

I used the following code while studying signals. #include<stdio.h> #include<sys/stat.h> #include<sys/wait.h> #include<unistd.h> #include<stdlib.h> #include<signal.h&...
0
votes
1answer
106 views

Does a forked process copy all mapped memory when writing?

I understand that a forked process maps the parent's memory and copies it when writing to it. Does it copy just what it needs written or does it copy the entire mapped memory ?
1
vote
1answer
101 views

Can I write a console program that works with multiple character encodings? [duplicate]

I am writing a console program in C. I expect the Terminal that my program is running in to have its character encoding set to UTF-8. This means that I am sending UTF-8 encoded strings to the ...
-1
votes
1answer
17 views

How can i send for 1 minute via a pipe, random numbers of 2 or 3 figures from the parent process to the child one?

Additionally to this task I have to count in the child process all the numbers received from the parent process and print them! Thanks in advance! :)
44
votes
4answers
7k views

Why does a program with fork() sometimes print its output multiple times?

In Program 1 Hello world gets printed just once, but when I remove \n and run it (Program 2), the output gets printed 8 times. Can someone please explain me the significance of \n here and how it ...