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
22 views

How does getpid() works?

The getpid() system call returns the process id of the invoking process. How does the kernel figure out which process is invoking the system call ?
3
votes
1answer
263 views

How do I use ctags functionality in vim with cscope installed?

When I install cscope by adding the line Bundle 'chazy/cscope_maps to my .vimrc file, my tags menu (g+[) is replaced with a cscope list, which seems to contain a list of files where the tag is called, ...
0
votes
0answers
27 views

How do I send a variable through SSH so it can be used across servers? C Shell

EDIT: Would this be possible in bash? Note: I have to use C shell. (.csh) I have something very similar to the following code: set var = "string" ssh -X server "$var" << END * I ...
3
votes
2answers
398 views

How to create GUIs (such as menuconfig) with lxdialog

I try to generate a menuconfig by my own with the help of lxdialog (source: lxdialog). Unfortunately this is not so well documented as I wished for. Example: So what I did: I included these files ...
0
votes
0answers
13 views

Incorporating GTK into Eclipse

I do not understand what is missing here when incorporating gtk2 into eclipse . First - I know I have the devs installed since I have already successfully compiled an gtk-app through a makefile. gcc ...
0
votes
0answers
8 views

structure variable is not set to 0 after applying the memset [migrated]

I want to know, how the value is printed for the below items. because i set the structure variable one to 0 using memset. but this variable is assigned in mainst.subst using init() method. ...
2
votes
1answer
26 views

System call 'open' mode not working

I am writing a simple code about opening a file with O_CREAT | O_WDONLY | O_EXCL flags. The code looks like this: int fd = open(fileName, O_WRONLY | O_CREAT | O_EXCL, 0777); It works well, except ...
0
votes
1answer
19 views

Difference between GNU AutoTool ToolChain, cross GCC and Linux GCC

I start using eclipse CDT. As I was trying to create project in C. I have to encounter with these options. When I select makefile project. I had options to choose toolchain from these GNU AutoChain, ...
-1
votes
1answer
41 views

Squid cross compile

I've been trying to cross compile the Squid 3.5.7 on ARM Cortex A8 (Linux). I downloaded it from http://www.squid-cache.org/Versions/v3/3.5/ I have arm-linux-gnueabi-gcc and arm-linux-gnueabi-g++. ...
-2
votes
2answers
51 views

Pipe Named Fifo [closed]

I am implementing a named pipe to write and read data between two processes in cpp. The first process acquires a feature point from an image in real time while the second reads this feature point. It ...
7
votes
2answers
5k views

Get CPU utilization stats from C program

I want to read the CPU utilization stats from a C program, I am interested in the percentage of use of CPU, steal time etc. These stats are shown in the 3rd row from the top command. I tried to parse ...
-1
votes
0answers
12 views

i am getting conflict error when trying to run the following code of read write locks using pthreads [migrated]

Here is the code for my program incr_rwlock1.c /* include main */ #include "unpipc.h" #include "pthread_rwlock.h" /* our implementation header */ #define MAXNTHREADS 100 int ...
-1
votes
1answer
38 views

Why does grep goes into blocking stage? [closed]

I am making a test My task will be one child pipelining the output to the input of another another child. I am using ps -ef as the first command(by using execlp()) and grep root as the second ...
0
votes
1answer
46 views

Trying to compile GNU Screen

I am trying to compile GNU Screen in my home folder on a machine where I don't have super user rights. I am taking GNU Screen version used by Linux from Scratch. tar xvzf screen-4.3.1.tar.gz cd ...
3
votes
1answer
954 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 ...
2
votes
1answer
2k views

what device name should I have to give in snd_pcm_open other than “default”

I want to record sound from 2 devices simultaneously: internal mic external usb webcam mic Using pulseaudio sound controller, I set either of these devices as default and could record sound with ...
0
votes
1answer
34 views

Two or more threads on single core [closed]

What are the advantages of using threads on single core, does that makes sense to use multithreading on single core?
0
votes
1answer
52 views

Why is my CD command not working on a home-built shell? [duplicate]

I have written a very basic shell in C. It reads the input, then runs it using system(lineCopy); (lineCopy being a copy of the input). All commands will run fine in it, other than cd. When I try to cd ...
-1
votes
2answers
117 views

Free or cheap shell (i.e., platform) to run a Linux C program with root privileges (raw socket)

I'm working on a Linux C program that needs root privileges (raw socket). I would like to run it on a host located in the US (I am in EU) to compare results. Is there any free (or cheap) shell ...
-1
votes
1answer
19 views

Daemon opens a file in RO mode only

I am trying to write a kind of keylogger myself. I don't know if my logic of developing a keylogger is good or not but I have thought of doing it the following way. First a daemon is created, and to ...
5
votes
2answers
2k views

How can I get a static C compiler?

I'm playing around with chroot environments, and I'd like to have a portable C compiler so that I can easily set up some basic build-tools in each environment without having to move too many libraries ...
1
vote
1answer
65 views

Undefined reference to math functions when linking with gcc

I'm getting an error when using make to install a program. The full step that it fails on with error looks like this: gcc -g -O2 -fopenmp -L/usr/lib -lcfitsio -lm -o lenstool_tab e_nfwg.o ...
7
votes
1answer
4k views

How can i know which unistd.h file is loaded?

I have several unistd.h files in my Ubuntu Linux. I've one on /usr/include/asm/unistd.h. This file has this directives: # ifdef __i386__ # include "unistd_32.h" # else # include "unistd_64.h" # ...
-2
votes
2answers
44 views

How to find only the name of a link? [closed]

Specifically, I need to write a C program where I put inside the pathname of a symbolic link and on output I print only the name of that symbolic link(not the name of the file pointed by the link). ...
1
vote
1answer
51 views

Cross compiling a software module

I'm trying to compile dropbear with the GNU ARM tool chain. I've went through this guide and managed to successfully build all the required tools. They are located in a directory: ...
1
vote
1answer
76 views

Compiling sources with a non-default compiler

I need to implement an authentication scheme on an embedded device and require gmp in order to perform large integer operations. After downloading the sources they must be compiled with a proprietary ...
0
votes
1answer
24 views

Linux server as a target for my C code [closed]

How to use a linux server as a target for my C code written on a different (Windows) machine. Including step by step debugging and etc... All that with Eclipse Env.
2
votes
1answer
159 views

How can I (easily) map a block device node to the directory it's mounted on?

I need to find (in C or C++) the used space on a filesystem (Linux) when being provided only with the disk block device name and the partition number. For most filesystems I can go: Craft a dev ...
0
votes
2answers
75 views

Pulling log messages for a particular log in systemd journal?

I was wondering if it is possible to pull log messages for a particular log with systemd's journal logging. For example, when I open a log in C, openlog('slog', LOG_CONS | LOG_PID, LOG_LOCAL1), to ...
6
votes
2answers
6k 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 ...
0
votes
3answers
464 views

Why Samba needs the VFS module?

I came across this picture when learning samba. I am confused with the VFS module in this image. Why we need this VFS module in samba server instead of passing directly the intend system call to ...
0
votes
0answers
57 views

custom gcc install include files

I have a custom installation of g++ 4.8.1 in my home directory. However the include files in that installation have no extensions! (except for tgmath.h, fenv.h, complex.h, and cxxabi.h) Thus even if ...
6
votes
4answers
3k views

chdir(<directory>) doesn't change directory after exiting to shell

I wanted to make a simple C program to change to my project directory. Its content is as follows: #include <unistd.h> int main() { chdir("/home/enedil/projects/algo"); return 0; } I ...
0
votes
1answer
27 views

How to determine which Berkeley DB version is used for RPM's database?

I am attempting to read and write the RPM database located in /var/lib/rpm under CentOS 5, and eventually other system types (CentOS 6, RHEL, etc.) The problem is that I don't know what version of ...
0
votes
1answer
56 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. ...
0
votes
1answer
74 views

How do I check if FFTW installed correctly?

I tried to install FFTW on my system (Ubuntu 12.04) using the rather unclear instructions on this website, and now I want to check if it worked. (FFTW is a C subroutine library for computing the ...
0
votes
0answers
52 views

I can fix/repair small damaged tar.gz files using fixgz but it doesn't work on bigger files

The title tells it. I have some damaged .tar.gz files, most of them are pretty small (smaller than 1-2gb) but 4 of them are bigger and fixgz cant fix them, when i run fixgz for those big files, it ...
0
votes
3answers
67 views

Are there obvious differences between learning C on OSX and learning C on Ubuntu?

I'm a python programmer, and today I start my journey of C. Now I'm using OSX, with Ubuntu in my Virtual machine, meanwhile our production servers are using CentOS. I suppose these three systems ...
1
vote
3answers
497 views

How to calculate the memory consumed by a “C” program in linux

I have written two C programmes one is using function pointer, and the other without function pointer. Now i want to know the memory consumed by the two programmes , to see how memory can ...
0
votes
0answers
83 views

how to increase Stack Size of a running program in C

I am trying to identify any way if we can increase the stack size of my running program after getting SIGSEGV. I know we can increase the size of stack by ulimit -c but, that did not solve this ...
-2
votes
1answer
35 views

Meaning of '&' in C (here in linux kernel function-like Macros) [closed]

#define TCP_SKB_CB( __skb ) ((struct tcp_skb_cb *)&((__skb)->cb[0])) What does the & mean in this context?
3
votes
2answers
83 views

When does cat finish reading from a pipe?

Given the following code, why does cat only print the contents of the pipe after I've typed \n or CTRL+D? What are the conditions for cat to actually print what it read? #include <stdio.h> ...
3
votes
1answer
77 views

Memory layout of dynamic loaded/linked library

when loading a shared library in Linux system, what is the memory layout of the shared library? For instance, the original memory layout is the following: +-----------+ |heap(ori) | +-----------+ ...
3
votes
1answer
73 views

Io redirection vs file logging performance c/c++

Is there a performance difference from a latency point of view if we do a regular printf and redirect stdout to a file when running the program ( e.g., ./a.out > log.txt 2>&1 ) vs using fprintf ...
5
votes
1answer
9k 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); ...
1
vote
1answer
78 views

How to get the authentication status from the last PAM module run

If I have the following PAM stack: auth required default_pam.so auth requisite my_custom_pam.so .... How do you obtain the authentication status from the last/previous PAM module run for use in ...
0
votes
1answer
45 views

Can I use LXC library in my c program?

Currently, I am designing a c program that will create multiple container and put different applications into them separately to achieve isolation. Is it possible to leverage LXC library to it? I ...
4
votes
1answer
507 views

Can I write C programs for Linux on OS X?

In case I'm writing a program (of any kind) in C, that is meant to be run on Linux environment, can I write it under OS X? (concurrency wise for example) I'm asking this because I like programming in ...
3
votes
2answers
231 views

The «sh» being launched with execl() becomes a zombie

I am spent whole half a day, but still couldn't figure, why is the dash being launched with execl call just becomes a zombie. Below is a minimal test case — I'm just fork a child, make a duplicate of ...
0
votes
1answer
36 views

What happens to TCP when a write fails to enqueue with the device tx ring?

Lets say the device tx ring is full and you do a normal C non blocking write(fd, buff) to enqueue data in the TCP SND buffer. What happens when this fails? In UDP - the packet would be dropped but ...