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.

learn more… | top users | synonyms

0
votes
1answer
24 views

How do kthreads actually work?

Need to implement DHCP server in kernel space. It's supposed to be a multithreading server, and I think I should use kthreads ( I'll be glade if you know better decision ). However I can't understand ...
-2
votes
2answers
12 views

Is the flag treated as string in c command argument? [on hold]

say I have the following: #include <stdio.h> #include <string.h> int main(int argc, char *argv[]){ if (argv[1] == "-s") { printf("success\n"); } else{ ...
-5
votes
0answers
21 views

How can I avoid this line from getting printed? [on hold]

I have this piece of code that I developed just to address a problem that I have in another large program that I am developing. My goal is simple, When the user enter quit. I will just display ...
0
votes
0answers
19 views

Most efficient way to replace a line in a text document? [migrated]

I am learning to code in Unix with C. So far I have written the code to find the index of the first byte of the line that I want to replace. The problem is that sometimes, the number of bytes ...
1
vote
0answers
61 views

error while compiling my first program in C language? [on hold]

I am a newer user of Ubuntu I used to compile c file via Code Block in Win OS. But now I've created a simple program (hello ,world!). This is the code #include<stdio.h> /* demo.c: My first C ...
1
vote
2answers
34 views

Generate raw Ethernet frames with memory preloaded payloads at < 1 ms intervals

I am looking to generate raw Ethernet frames with payload that is preloaded into memory. The Ethernet frames (10-60 full frames) should be generated at 1 ms intervals with no exception. What would ...
2
votes
1answer
25 views

Compute total CPU usage of a PID namespace

I'd like to monitor the CPU usage for all processes in a particular PID namespace. I'd like to do it programmatically (C, if possible). I have an idea of how to do it, but I'd like to know if Linux ...
0
votes
0answers
15 views

openpty returning zero as master file descriptor

I am opening a pseudoterminal with openpty function. This will be used to redirect some data coming from a serial port into an external application (in this case, a GPS receiver). The fact is that ...
1
vote
1answer
20 views

Merging text file directories

I have two directories: Libc-825 and Libc-1044. Imagine that version 1044 is newer, but buggy. Is there a way to merge these file trees? I have there C sources with not so big differences. I have ...
1
vote
0answers
51 views

How do C programs pass whitespace arguments to the libc system(3) calls? [migrated]

When a C program calls system() to run a Unix command, I know it's possible to pass arguments to the command, and according to a StackOverflow answer (from a very high-rep user), the system() call ...
-2
votes
1answer
34 views

What does the -p option do exactly with the cp command?

So I am trying to understand what is the significance of the -p option for the cp command. I opened the manual of the cp command and it says -p same as --preserve=mode,ownership,time stamps. But ...
0
votes
1answer
20 views

openSSL Key and Certificate

As far I know, in an authenticated SSL connection, both the client and server have private keys and provide their certificates (with the corresponding public keys) across the connection before ...
0
votes
0answers
14 views

Linux RPC call is slow [migrated]

The following RPC program executes very slow on fedora. if i change the name buffer into name [512] in llist.x file, then its working fast. I dont know why. Anyone know the reason please let me know. ...
0
votes
2answers
27 views

Sleep system call and its time parameter

Let's say that we are writing a C program that calls the sleep() function. For instance, by calling sleep(7), the calling thread would be put to sleep for 7 seconds. My question is: Will the thread ...
0
votes
0answers
22 views

Cant understand the implementation of max function in the linux kernel [migrated]

What's the significance of (void) (&_max1 == &_max2); in the following definition of max found in Linux/tools/lib/lockdep/uinclude/linux/kernel.h? #define max(x, y) ({ ...
6
votes
1answer
51 views

Get header of the C function from BASH

I want to get the header(s) that I need for a given C function - e.g. when I want to see what to include when I want to use fork(), I can type out man fork and see that it's #include <unistd.h>. ...
1
vote
0answers
14 views

how to use when a lib function has the same name with it's system call? [migrated]

code as follows, sched_yield() has the same name of lib function and system call, I don't know sched_yield() in the code is a lib function or a system call, how to distinguish? #include sched.h void ...
0
votes
1answer
51 views

Process tree using fork() [closed]

I am given the task of creating this process tree in C using fork, if and else: |_____1___ |___2__ | |_4_ | |_3_ | | | | | Or as a pstree like drawing: p(0)─┬─p(1)───p(3) ├─p(2) ...
-1
votes
1answer
21 views

IOCTL() Library for Windows [closed]

I am trying to cross compile my c code from debian linux to a windows platform. I have worked out most of the kinks but I am struggling with ioctl(). Windows doesn't seem to have a ioctl() equivalent ...
1
vote
1answer
50 views

Get output of `posix_spawn`

So I can run a process in Unix / Linux using POSIX, but is there some way I can store / redirect both the STDOUT and STDERR of the process to a file? The spawn.h header contains a deceleration of ...
1
vote
1answer
81 views

mount overlayFS as Read-Write FS

I want to mount my RO Filesystem using overlayFS - in order to use two layers FS (Lowerdir and Upperdir). I tried the following mounting command - mount -t overlayfs -o lowerdir=/,upperdir=/overlay ...
2
votes
1answer
41 views

Compiler for 32-bit LSB MIPS MIPS32 architecture

I have a TV set top box that i'm currently experimenting on: I established a serial console connection to it through a serial port located on the board. I am trying to compile a simple C executable ...
-3
votes
2answers
48 views

C Programming on command line [closed]

What to do after opening vim name.c and writing the source code? I mean, to compile and execute.
0
votes
0answers
16 views

Error libGL dlopen

I am starting learning SDL. I am reading a tutorial and it has this code: #include <SDL2/SDL.h> int main( int argc, char* args[] ) { SDL_Init(SDL_INIT_VIDEO); return 0; } And when ...
4
votes
5answers
214 views

File descriptors across exec

By default file descriptors remain open across the exec functions. The benefit is perhaps understandable for descriptors 0-2. But is there a practical use case for keeping other descriptors open? Are ...
2
votes
0answers
16 views

how to build kernel-tools-4.2.xx.rpm and kernel-ltools-libs-4.2.xx.rpm

I am trying to upgrade Centos-7 kernel (kernel-3.10) to (Kernel-4.2.6) and for that I downloaded kernel from kernel.org and create rpm for the custom configuration (arch x86_64)using "make rpm". ...
2
votes
0answers
43 views

Look up documentation on C types?

I'm reading over documentation on concurrency in C and trying to learn how to do things concurrently. As I'm reading, I'm coming across types I've never come across before like tss_t, etc. Is there ...
0
votes
1answer
26 views

Server port doenst go back to listen and is in closed_wait state , because of starting an daemon application from client

Below is the basic client and server code . While iam trying to start an appliaction(which has to keep running in the machine once we send a msg to server) during connect call. using ...
0
votes
0answers
15 views

How To Patch Bugs Manually in Software [duplicate]

We have been experiencing issues with winbind on our servers and I found a thread on Bugzilla regarding a bug which sounds much like the issue we are experiencing. Throughout the discussion, the ...
1
vote
1answer
67 views

Why is my stdbool.h not in /usr/include?

I'm used to standard C header files being in /usr/include (e.g. stdio.h, stdlib.h, string.h, ctype.h and so on); yet - stdbool.h isn't. Now, I know it's newer than the rest, only being part of C99. ...
0
votes
1answer
43 views

How to write a Patch for VyOS kernel

I am new to VyOS development. I have written a patch which will fetch info from the VyOS kernel module and write it on a netlink socket. But the problem is I am not sure if I should edit the kernel ...
1
vote
1answer
67 views

Using gcc compile flags

I am trying to understand how to properly setup gcc to find stuff in my environmental variables. Currently I compiled some code, SDL and I added it to my .bashrc and sourced that .bashrc as well. ...
2
votes
1answer
32 views

building code from source and adding them to your path

Typically on Debian when you install things from the repository, they just work. It sets up things just fine and life is good. This is great for things that are up to date in the repository. I am ...
2
votes
1answer
60 views

Bash shell launched by forkpty() spawns child processes that ignore SIGINT. Why and how do I ensure SIGINT is not ignored?

I have a C program that uses forkpty to execute a bash shell. I'm finding that the programs launched by this shell are launched with SIGINT ignored, so when I send a Ctrl-C to the shell they never ...
1
vote
1answer
115 views

generate consistent machine unique ID in c programming

Is it possible to generate a unique ID that wouldn't change over time unless there is hardware changes. The hardware must be generated with a c program. That also would be great if it were robust to ...
1
vote
1answer
22 views

How to make program which will react on button pressing (such as “more” on 'q') [closed]

I' m trying to realize, how does work pg\more\less utilities. For example, cat somebigfile | more. More now in interactive mode. His fd table is: 0 (read pipe from cat) 1 (stdout) 2 (stderr) I can ...
0
votes
1answer
46 views

Calling a shell rsync command from C

I am creating a basic C file in order to learn the basic Linux commands a little better. I am trying to implement a tar back up function. I am struggling to implement it in C (still learning C) so ...
1
vote
3answers
177 views

How to make the shell execute only external echo, not the builtin one?

I have a C program which uses system() library function. Below is the source code. #include<stdlib.h> int main() { //Some code system("echo Hello World"); //some code return 0; ...
1
vote
1answer
65 views

Changing a Users Default Shell

I have created a simple C shell on my local Linux server. I am trying to learn how to change the default shell of another user (bob) to be this new C shell that I have created. Is it possible to ...
5
votes
1answer
650 views

Where is `scanf` implementation source code?

I want to find C source code for scanf implementation on Linux machine. Googling to find scanf implementation does not tell me the way to find it. I tried to find that source code from gcc source tree ...
0
votes
0answers
30 views

custom runtime environment - libpthread segmentation fault

I have built a project using gcc 4.9.2 (libstdc++.so.6.0.20). When I want to run that program on the virtual machine which is equipped with gcc 4.6.3 (libstdc++.so.6.0.16) I have to deliver ...
2
votes
0answers
43 views

How to remove a broken installation of glibc

I just attempted to install glibc version 2.19 to my computer as follows: 1) I cloned the glibc git repo with $ cd ~ $ git clone git://sourceware.org/git/glibc.git 2) I checked out version 2.19 ...
0
votes
0answers
62 views

system user + kernel time using /proc/stat

user: normal processes executing in user mode nice: niced processes executing in user mode system: processes executing in kernel mode idle: twiddling thumbs iowait: waiting for I/O to complete irq: ...
2
votes
1answer
144 views

Why does a “child” process finish before its parent?

This is the code example given: # include <stdio.h> # include <unistd.h> void main() { static char *mesg[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}; int display(char ...
2
votes
0answers
83 views

Can I add iptables rule from the inside of a C Linux program only with capabilities or do I need necessarily root?

I need to add an iptables rule from the inside of a C Linux program. How should I do? Do I need root privilege or can I just grant some capabilities? I tried granting CAP_NET_RAW+iep and using ...
1
vote
0answers
138 views

Error building and compiling GCC 5.2.0 from scratch on Vortex86DX

In order to upgrade a VortexDX86 custom linux with a gcc 3.2.3 compiler, I´m trying to built the GCC 5.2.0 compiler to support the latest C++ 11 standard. I have downloaded its source code from ...
-1
votes
1answer
125 views

Forwarding return value of shell script to C/C++ [closed]

I tried to find possible solution on Google, but all I found is explanation on how to return value, but not how to accept it in some programming language, in my case C/C++? Does anybody have idea on ...
0
votes
1answer
19 views

segmentation fault/ not booting main from rcS

I'm trying to boot a 'main' executable from the rcS file /soft/main & 2>&1 >> /var/log/app.log & but I'm getting a segmentation fault witch is strange because when i cd to the application ...
-2
votes
1answer
48 views

factorial program does not return prompt [closed]

This program (factorial.c) is running but it does not return the prompt at the end, unless you hit enter: #include <stdio.h> int main() { int num, i, fact = 1; printf("Enter a number to ...
0
votes
1answer
222 views

convert executable back to C source code

Unfortunately I lost my source code and I just have the output file that made with gcc in linux and I don’t have any access to my pc now.is there any way to convert output file to source file (in c ...