Stack Exchange Network

Stack Exchange network consists of 175 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
16 views

How to empty the list of supplementary group IDs for a process?

When I create a child process, it inherits the supplementary gids of the parent. If the parent is a root, then the child has (0) as supplementary gid. This behavior is not desired. Is it possible to ...
-3
votes
0answers
24 views

union of two arrays [on hold]

i wrote this code below but this code isn`t working i want to make union of arrays but arrays contain negative numbers. #include<stdio.h> int printUnion(int arr1[], int arr2[], int m, int n) ...
-2
votes
0answers
26 views

convert char array containing ipv6 address to dotted ipv6 format using network APIs in linux [on hold]

I want to convert an array type char contains raw IPv6 address to IPv6 dotted format using network APIs in Linux environment. eg: i/p = fe80000000000000020d41fffe121400 o/p = fe80:0000:0000:0000:...
0
votes
0answers
16 views

How to remove all but last 10 files using c++ without using system() [migrated]

how to implement system("ls -t1 . | tail -n +11 | xargs rm -rf") without using system(). i want to keep only latest 10 files in my linux folder rest of them should be removed when i call c++ function.
2
votes
1answer
51 views

Prevent Bash from removing zero-bytes in double-quoted string?

I need to supply arbitrary bytes for an argv argument of a C program. However, if the bytes are put within double-quotes, the zero-bytes are removed as can be seen below: v="$(python -c 'import sys;...
1
vote
1answer
30 views

CPU statistics calculation algorithm

I too many search on internet to found algorithm calculated %Us , %Sy , %Id , ... on result of top command . but can not found any documentation . some documents like this or this calculate cpu ...
1
vote
1answer
79 views

Shell crash and how to debug it

As part of my C application running on Linux, I call a script using the system( ) library function. This script does a umount of a connected USB flash drive. Very rarely (1 in 7-8k) iterations, I see ...
0
votes
2answers
52 views

Trying to do a Proof of Concept of poisoning 'ls' binary to hide files and folders

I am currently trying to modify 'ls.c' source file in order to hide files and folders containing the word hidden. After doing some research, I've found that this could be possible by adding this code ...
0
votes
1answer
23 views

Read arbitrary amount of memory with process_vm_readv

For process_vm_readv the linux man page states: [...] (Avoid) spanning memory pages (typically 4KiB) in a single remote iovec element. (Instead, split the remote read into two remote_iov elements ...
3
votes
1answer
384 views

Determine free space available on a USB flash drive in C (linux)

I would like to figure out the available free space on a USB flash drive in a C program in Linux. I have earlier used system("df -h /dev/sda1") to figure it out but using system command in a Linux C ...
2
votes
0answers
33 views

Kernel can't find initrd?

When trying to mount ext2 I get this error: Creating 4 MTD partitions on "MPC8313RDB Flash Map Info": 0x000000000000-0x000000100000 : "U-Boot" 0x000000100000-0x000000300000 : "Kernel" 0x000000300000-...
8
votes
1answer
1k views

How different is compiling source code in Debian GNU/Hurd from Debian GNU/Linux?

I was trying to compile libnetfilter_conntrack source from github as it was requested by iptables while compiling iptables and as any of these were not available in the HURD software repo and ended up ...
0
votes
0answers
31 views

How to programmatically get a hostname's IP address on a local network in C?

I'm working on a project where I'd like to transfer data over TCP/IP sockets in a C program between two computers connected over WiFi to a home router, both are running Debian-based Linix ...
0
votes
0answers
19 views

In Linux, I am having a hard time using GTK to draw text [migrated]

I try to type this code to display text on the screen but there is no text when I compile and then open the compiled app. Why wont this work? I am using C and Linux and I am trying to use gtk header ...
1
vote
0answers
14 views

Calling a c library function from within ctypes python [migrated]

Using nm, I get these functions back from my library: 0000000000004bc0 T __Z13generator_sind 0000000000004120 T __Z13librador_exitv 0000000000004080 T __Z13librador_initv 0000000000004b70 T ...
0
votes
0answers
7 views

What is the difference between crypt in unistd.h and crypt.h? [migrated]

crypt has two definitions, from the docs, One of them uses unistd.h #define _XOPEN_SOURCE /* See feature_test_macros(7) */ #include <unistd.h> This is defined as #ifdef __USE_MISC /* ...
0
votes
2answers
41 views

Text from standard input not visible after program exits from a readline

I am facing an issue where the text from my stdin is not visible from on my terminal. My program does the following Sets a SIGALRM handler which exits a program when there is no input from the user ...
1
vote
1answer
51 views

Detect if USB disk is mounted in C application in Linux

I would like to check if USB disk is mounted in a C application. I know that in a script I can accomplish this via mount | grep /mnt (the mount point where udev mounts the USB drive) but I need to do ...
3
votes
1answer
120 views

How is the C library able to access environment variables?

This may be a dumb question, as I feel like I must be overlooking something fairly obvious, but how do functions like getenv(3) access the environment when my program doesn't have any references to ...
4
votes
3answers
255 views

Passing generated empty strings as command line arguments

I do the following: $ ./input "" Output: argc 2 argv[1][0] 0 But if I want to pass (several) empty quotes in program based manner: $ python -c 'print "\"\""' "" ./input $(python -c 'print "\"\""'...
5
votes
1answer
44 views

%c formatted string shows different behaviour in the shell and in C

If i write a very simple line of code in C: printf("Ascii char for %d is %c\n",65,65); It simply prints A, as ascii value of 65 corresponds to character A. But if I use the same code in shell and ...
1
vote
0answers
17 views

Can I limit a process's access to specified files and stdout only without root?

I want to setup a server for students to upload C code. The server compiles C code, run the binary and shows output to students. Now I am having security concern. Students can upload any code, but I ...
1
vote
0answers
41 views

seteuid fails even when all UIDs are 0

I have some C++ code on a Linux machine whose purpose is to run some code as an arbitrary user. #include <sys/capability.h> #include <unistd.h> void doAsUser(uid_t uid) { if (...
2
votes
1answer
31 views

Why does GNU Indent collapse one level of indentation?

When I try to format my C code using GNU Indent, it doesn't seem to deal with multiple levels of nested indentation. Specifically, it seems to collapse the second level of indentation. For example, ...
-2
votes
0answers
17 views

Problem with GCC compiler [migrated]

I am using Arch Linux and when I am compiling and running the following C code, #include <stdio.h> #include<string.h> int main(void) { char s1[]="Hello"; char s2[]="World"; ...
-2
votes
1answer
29 views

How to write a script to kill & clean the resources of executing process?

I have an application running in c language (my_process.c) and a script (stop_process.sh) to stop the application and clean up all resources held by the process. In the application code, let's say I ...
0
votes
1answer
64 views

Still safe to use distro after applying c program to it?

I installed elementary OS Juno on an old iMac 5,1. The Computer uses a 32bit EFI, which is not able to boot elementary OS Juno so I decided to follow Matt Gadients guide for a little workaround. You ...
0
votes
1answer
54 views

How to grep using gcc to find definitions in standard librarys [closed]

I have found in my project a type definition, which is definitely from a standard library. Lets say the definition is called uint64_t I know #include <stdint.h> #include <string.h> #...
-1
votes
2answers
64 views

Child processes seem to run code from before they were created. How do I stop it?

I'm trying to write a program that has a single parent process create multiple children in a while loop. For testing I started trying to make only 4 processes (1 parent and its 3 children). But it ...
0
votes
1answer
22 views

Stopped process reasons?

I'm running a program using a batch file and it keep giving me this ERROR: STOPPED PROCESS I've noticed that the program stops each time in a place a little after the place he stopped the last ...
7
votes
5answers
545 views

Executing a bash script or a c binary on a file system with noexec option

Can anyone explain in details what is going on with the following. Let's imagine I am mounting a directory with noexec option as follows: mount -o noexec /dev/mapper/fedora-data /data So to verify ...
0
votes
0answers
66 views

How to supply a command to 'stdin' of a running process from a second shell?

If you have a process that is waiting for user-input from the stdin scope, then how can you supply that user-input from a second terminal ? Specifically, if I run the c-program while(1){ fgets(...
0
votes
1answer
42 views

Linux kernel module development buildroot

I have build a linux kernel for the beaglebone black using buildroot. Now I would like to develop a hello world linux kernel module application: #include <linux/init.h> #include <linux/...
0
votes
1answer
47 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
34 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
60 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
16 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
32 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 ...
0
votes
1answer
40 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
59 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
57 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
166 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
116 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 ...
1
vote
1answer
30 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
202 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
74 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
201 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
126 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
1answer
283 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
99 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=/...