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

16
votes
2answers
10k views

While there is C++ why most of Linux programs are written in C?

Why most of linux programs are written in C? Why they are not written with C++ which is newer than C?
0
votes
0answers
12 views

F_GETPIPE_SZ returns -1 in C [migrated]

Why would F_GETPIPE_SZ return -1? It sounds like an error, but I can't find any mention of what error it is, or, more importantly, what I'm supposed to do to not get the error. I'm running Raspbian ...
7
votes
2answers
121 views

Make GNU indent break long comments

Is there a way to convince GNU indent to break long comment and change it to multiline comment? Something like this: // Very long comment, longer than 80 characters. Just imagine that. To this: /* ...
0
votes
2answers
70 views

parsing using loop and assigning row numbers to file

It is a bit complicated. i have a configuration file. it looks something like this. customer="airtel" model_name=fast programmer_typ_of="dev" Now the 1st column contains all the keys and whatever ...
1
vote
0answers
300 views

libpcap missing

I’m trying to run a C program, but every time I try to run it I get this message: error while loading shared libraries: libpcap.so.0.8: cannot open shared object file: No such file or directory I'...
-3
votes
0answers
26 views

what rule causes infinite loop program to stop a 'C' program [migrated]

I am running this below 'C' program which is an infinite loop. I see the CPU reaching almost 99% using the 'top' command. then suddenly the program stops. I was curious to know what rule in the system ...
3
votes
1answer
31 views

Determine the name of the static/dynamic library

Quite often I am using third party snippets of c code that uses a Unix/Linux c library, an example #include <glib.h>, #include <net/if.h>. And they require me to know the specific library ...
1
vote
1answer
38 views

SSL related “undefined reference” on libssh2 and libcurl libs when compiling C on OpenSUSE

I been trying to compile a C software but I'm getting 'undefined reference' over SSL libraries I think. The libraries it mentions are there, actually I compiled them all again: zlib + openssl + ...
1
vote
0answers
11 views

Basic mmap implementation [migrated]

I am pretty much new to linux and am writing a custom driver for which I need to use mmap. I have found the sample code in many places as below static int simple_remap_mmap(struct file *filp, struct ...
2
votes
2answers
121 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. ...
10
votes
3answers
9k views

How can I find a memory leak of a running process?

Is there a way, I can find the memory leak of a running process? I can use Valgrind for finding memory leaks before the start of a process. I can use GDB to attach it to a running process. How could I ...
3
votes
1answer
1k views

ioctl: invalid argument for HDIO_GET_IDENTITY

I wrote a program to get the details of hard disk drive using HDIO_ ioctl calls. For writing program, I'm referring Documentation/ioctl/hdio.txt in kernel source(2.6.32). Here is my main part of ...
1
vote
0answers
26 views

can two android devices in different network(3g) comunicate themselves with ssh connection?

I have two rooted android devices with different isp(i use different 3g connection for them) and created a double ssh connection(i can with a public ip server)comunicating both to this server(i have ...
0
votes
0answers
20 views

Strange PFN read from pagemap

I m trying to find the physical page to which a range of virtual addresses are mapped in a piece of C code that I ve written. I m using the /proc/self/pagemap to read the mapping. I ve used the code ...
4
votes
0answers
31 views

Linux application development and signal handling

Currently I am having problems with my users complaining about the termination of my application. Under some (seemingly arbitrary) conditions and desktop environments the app is not terminated and ...
0
votes
0answers
22 views

Compile project with cmake for OpenBSD 5.9

I'm writing a shell and have compiled and run it with Ubuntu. It previously built and ran with OpenBSD 5.9 earlier, but now I get compiler error that I don't understand. $ make [ ...
0
votes
0answers
62 views

Where are the definitions for the prototype declarations in <bsd/stdlib.h>?

I have a C program on Ubuntu 16.04, in which I would like to use arc4random_uniform. typedef unsigned char u_char; #include <bsd/stdlib.h> int main () { return (int) arc4random_uniform(100); } ...
0
votes
1answer
29 views

Checking that $((a * b)) evaluates in my own shell [closed]

POSIX seems to define that a shell should be able to evaluate like a calculator the expression $(( a * b)) where * is a binary operator +, - or *. I programmed such a calculator for my own shell and ...
1
vote
1answer
45 views

How to read from another terminal?

I opened two terminals (/dev/pts/1 and /dev/pts/2) and started my application from /dev/pts/1. I want to read in real time from /dev/pts/2 but my code doesn't work: actually some of the symbols are ...
5
votes
2answers
18k views

Default stack size for pthreads

As I understand, the default stack size for a pthread on Linux is 16K. I am getting strange results on my 64-bit Ubuntu install. $ ulimit -s 8192 Also pthread_attr_init(&attr); ...
0
votes
1answer
35 views

Can all of fork(), exec() and system() be wrong? [closed]

I understand why it could be less than best practice if I write C code that executes shell commands by calling system() and that it's better to use exec and fork but then a very experienced C ...
214
votes
4answers
76k views

Why is FreeBSD deprecating GCC in favor of Clang/LLVM?

So I was surfing the net and stumbled upon this article. It basically states that FreeBSD, starting from Version 10 and above will deprecate GCC in favor of Clang/LLVM. From what I have seen around ...
1
vote
1answer
87 views

Using Named Pipes in Bash created in a C Program

I have a C code that takes a rather large input. At every iteration, it processes a small chunk of it and it should send that processed chunk to S3 using curl. In the end, it will generate a number of ...
3
votes
3answers
208 views

POSIX compliance of the cd program?

Is globbing and shell expansion same thing? I'm learning C by writing a custom shell and I'm also learning POSIX. Now I wonder if it is POSIX compliance that cd - takes you back and that ~ means home ...
2
votes
2answers
73 views

How can I find out what linker flags are needed to use a given C library function?

Running example C code is a painful exercise unless it comes with a makefile. I often find myself with a C file containing code that supposedly does something very cool, but for which a first basic ...
1
vote
2answers
46 views

How to extract a function from file? [closed]

I am looking for a command to extract a C function from my code. It would be something like: $ grep -func "MyFunction" foo.c int MyFunction(int i) { return i+1; } I know we can extract it with ...
0
votes
0answers
36 views

Build location-independent GCC binaries

I have some problems with GCC. I want a portable version of GCC because the PC I use for programming cannot be connected to Internet due to some driver issues. So, I read an article on how to compile ...
0
votes
0answers
13 views

Error with libraries after setting up Code::blocks to work as an arduino IDE

First of all I apologize in advance if this is the wrong community, you're welcome to advise me another one to post. I followed this guide: http://arduinodev.com/guide-to-arduino-development-...
0
votes
0answers
14 views

Error occured with USB modem

I have MPC8309 Tower Board and connected USB Modem to it and then established Async PPP on Modem, now I started applying ping from different terminal from my laptop by applying nat commands and ...
0
votes
1answer
82 views

Maintaining single binary across Debian distributions

We are currently migrating our system from Debian 6 to 8. The agenda is to try to maintain single binary across OS platforms (x86 based) However, I tried running a Debian 8–compiled binary in ...
1
vote
1answer
77 views

What is the number at the top for the results for ls -l? [duplicate]

When you type in ls -l, there is a number on the first line labeled "total 22037"? What does this number mean? I am attempting to write my own version of ls -l( in C), and how do I get this value or ...
0
votes
1answer
20 views

Busy /dev/gpio. I can shared it?

I need shared one device between two C applications. This device is a buzzer. I've try open this with O_NONBLOCK flag, but result is same: device or resource busy. Is there any possibility to use the ...
1
vote
1answer
93 views

Why do the Linux kernel headers contain references to nonexistent headers?

I'm trying to build IBCS (source here) on Ubuntu 15.10 (Linux 4.2.35). This module is obviously pretty old, because its CONFIG.i386 file gives gcc an option -m486, which doesn't exist anymore, but ...
0
votes
0answers
30 views

How to call a device's power management methods in another way than during suspend to ram?

Let us consider the e1000e driver for an Ethernet card. This driver provide two power management methods .suspend and .resume to respectively turn off and turn on the card. Those methods are naturally ...
2
votes
1answer
68 views

pkg-config output not working with makefile?

I'm trying to run the makefile, shown in this repo, which is a simple Wayland client. But when I run make, it seems that the output of $(WAYLAND) is blank, and it fails to compile due to not being ...
1
vote
0answers
45 views

Is the (Free)BSD Codebase ANSI Compliant?

Google does not seem to shed any light on this topic - But the question is quite simple: Is the FreeBSD (Or any BSD) CodeBase ANSI (c89) Compliant, or does it use c99, c11 or non-standard features ...
3
votes
1answer
52 views

No stdlib in UNIX v7?

Browsing through the v7 UNIX Sources I noticed there is no "stdlib" directory - further more using a v7 UNIX Emulator, there is no such file as <stdlib.h>. However functions like exit() and ...
0
votes
1answer
166 views

how to define the top dir in automake system?

I usually use a typical steps to generate the makefile, and firstly I use the "build.sh init" to generate the configure file, and then I use "configure" to generate the makefile with makefile.am file. ...
1
vote
0answers
26 views

Unable to establish PPP on USB dongle?

I have USB Dongle and i am willing to setup ppp through the dongle. I have done following steps to setup ppp. 1.When i plugged the dongle into Ubuntu 14.04. It has been detected as the Mass ...
2
votes
1answer
44 views

non-reentrant libraries in shared memory?

I found this Q&A saying shared libraries can be shared between processes using shared memory. It seems like it would be impossible, though, to share code between processes without some pretty ...
1
vote
0answers
27 views

I2C Read unexplained data [closed]

I am trying to communicate with a PHY device using I2C primitives (read()/write()) in C language in user space. And i am getting some unexplained output in my program. First, the bus number is 2 and ...
0
votes
2answers
45 views

Parent process always printing output after child

Consider the following code running under Solaris 11.3: int main(void) { pid_t pid = fork(); if (pid > 0) { printf("[%ld]: Writing from parent process\n", getpid()); } if (...
1
vote
1answer
47 views

Location of executable file formed after compiling a C program

I have compiled my C source code using: gcc filename.c It got compiled, but I cannot see the executable in the same directory where my source code is. But when I compile my program using: gcc ...
1
vote
1answer
889 views

Cannot find -lgcc

I'm trying to compile my next basic c program after hello-world. This contains two supporting modules. I have Ubuntu running in a VM through VirtualBox on a mac. Everything is up to date but I can'...
1
vote
2answers
42 views

Run an executable as a service on a port

I have a C program (say a simple Queue system) which I compile and get an executable file. I want to run this executable as a service on a specific TCP port on a CentOS system which I can connect to ...
0
votes
0answers
190 views

Building Handbrake on Debian Jessie

I have found a web site that explains how to install Handbrake 0.9.9 on Jessie. The explanations there seem a bit outdated, because it advises to use SVN to get the sources, but Handbrake has switched ...
0
votes
1answer
87 views

How does one establish SIGRTMIN at run-time?

Reading up on signal(7) I can see that now: two, but once: three; signal numbers past 31 are reserved for use by the Real-time signal system and should not be used: Real-time Signals Linux ...
7
votes
2answers
10k views

How does copy-on-write in fork() handle multiple fork?

According to Wikipedia (which could be wrong) When a fork() system call is issued, a copy of all the pages corresponding to the parent process is created, loaded into a separate memory location by ...
1
vote
3answers
132 views

Trouble with creating an empty file using C programming language in UNIX environment

I have recently started programming in UNIX environment. I need to write a program which creates an empty file with name and size given in the terminal using this commands gcc foo.c -o foo.o ./foo.o ...
0
votes
0answers
8 views

GDB not copying desired string (Buffer Overflow attempt)

Ok so I am trying to learn about buffer overflows and there is this simple program that is vulnerable of a BoF because it copies the first argument into a buffer of 5 characters. In the source code, ...