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

6
votes
2answers
3k 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 ...
2
votes
1answer
253 views

What is parallel memory allocation?

I'm trying to understand what parallel memory allocation is. I think I understand what 'memory allocation' is but I don't understand the term 'parallel'. Something to do with multiple processors ...
1
vote
1answer
370 views

Dynamic linker “no version information available”

When I copy over a program and a few libraries it needs to another machine I get the "no version information available" when I run LDD on the program. I know why this is happening, I just want to ...
4
votes
3answers
281 views

Why is there a type for process ids (pid_t), but not for file descriptors (fd)?

I see that pid_t is typedef'd in unistd.h, and file descriptors are defined to be int in fcntl.h. But since they are used in similar ways, wouldn't it make sense to have a typedef for file ...
3
votes
1answer
135 views

In Emacs, editing C, sort-fields not working, or stating sole completion. Why?

In Emacs, editing C, and trying to execute sort-fields doesn't seem to be working. I enter M-x sort-fields after highlighting a region. At one point it was letting me pass a field number, but then ...
0
votes
1answer
81 views

Looking for resources: like C doc for reading files and their attributes? (On Linux)

Looking for resources: like C doc (something like JavaDoc for C on Linux would be cool) for reading files and their attributes? I'm working on recursively reading in files. I can get a list of files ...
3
votes
1answer
1k views

What is syscall-template.S?

I've come across a file syscall-template.S more specifically its location is .../sysdeps/unix/syscall-template.S What is this file? Where is it. It is not on my system and I cannot find it in ...
5
votes
1answer
23k views

gcc can't link to pthread?

I have recently installed XUbuntu 11.10 64bit, but I am having problem compiling the most simple pthread example. Here is the code pthread_simple.c: #include <stdio.h> #include ...
4
votes
2answers
3k views

How to find the header file where a c function is defined?

Is there an easy way to find out which header file a C function declaration is in? cding into /usr/include and running (grep -E 'system.*\(' *.h -R) works with some trial and error, but isn't there an ...
3
votes
1answer
2k views

Virtual unix command-line environment on the iPad

Is there a lightweight virtualized Linux or other unix environment that I can run on the iPad? Like VirtualBox for iPad. I only really need a minimal system — something along the lines of Microcore ...
5
votes
1answer
1k 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 ...
0
votes
0answers
282 views

network device module equivalent to ping

I have made a module which is transmitting but I don't know whether the packet which I am transmitting is a ping packet or not. Code is shown below: icmp.type = 8; icmp.code = 0; ...
2
votes
1answer
278 views

libfaketime and Mac OS, LD_PRELOAD

Running Mac OS 10.7.2 and trying to run libfaketime and nothing happen. I installed and ran exactly as directed only the time and date stay exactly as are set in the system? Is anyone else able to ...
1
vote
2answers
4k views

How to directly read keyboard input in real-time?

I am not certain if this is ultimately the correct place to ask this but I am developing a program which requires real-time input from the user. That is; it needs to be able to read the keys being ...
4
votes
1answer
1k views

Sparse files/file holes and unexpected block size

For my own learning, I've been playing around with creating files with file holes. I created a util that simply reads from stdin and writes to a file, but before writing to the file, it uses lseek to ...
2
votes
1answer
324 views

Unable to access linux/skbuff.h

I am writing a kernel module where I need to access sk_buff variables. But when I write #include <linux/skbuff.h> Netbeans says it can't locate that header file.
2
votes
1answer
578 views

Redirecting output when I execute “bash -c …” from a C program

Say I have a C program and in it I want to execute a shell command and redirect its output to file, by using the stdlib system function. system("bash -c \"echo $HOME\" > a.txt"); Now this is for ...
5
votes
2answers
3k views

How to run a C program as a daemon?

I have a C program which I want to run as a daemon. How do I install it so it will run as a daemon on CentOS? Someone said to use @reboot, and some said to put it in /etc/rc.d/rc.local. Which is the ...
4
votes
1answer
2k views

Writing to stdout except for output redirection C

I have to make a simple app for school. I have to write arguments one per line on the terminal, and return on stdout the user choices. For example, I write cat my_app main.c main.h, if the user ...
5
votes
4answers
1k views

Error while loading shared libraries

My project tree looks something like that: src/ include/ Makefile lib/ lib/3rdparylib/ I didn't code 3rdpartylib, but decided to embed its source code in my project packaging. I compile the ...
2
votes
1answer
2k views

gcc: -pthread: No such file or directory

Trying to compile following code in terminal i got gcc: -pthread: No such file or directory, what does this error means and how to eliminate it? file name: window.c code: #include ...
9
votes
1answer
2k 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
2answers
363 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 ...
4
votes
3answers
302 views

“which” equivalent for shared libraries

I am looking for a utility that would behave in the same way as which, but to look up shared libraries (*.so) in the directories defined in $LD_LIBRARY_PATH?
6
votes
2answers
180 views

System programming: How to gather info?

According to this question, a good way to learn system programming would be to implement the existing tools. I decided to try to rewrite ls and ps. My question is how would one proceed to get ...
6
votes
2answers
3k 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 ...
2
votes
1answer
1k views

How to capture from instensive pro in Ubuntu, Fedora, CentOS using HDMI interface?

I am trying to use PCI-X1 capture card (intensiy pro) using Ubuntu 10.04 (now) / 11.04 (failed) or Fedora (failed). None of them is yet capturing. I did my best but now i need some backup on this. ...
4
votes
2answers
5k views

“sys/ioctl.h” header in linux

I am on Linux 2.6.32-26-generic When I look in to the linux source code for "ioctl.h" hearer file, I could see many variants. (for different platforms, I guess). i.e. ./fs/ocfs2/ioctl.h ...
16
votes
3answers
10k views

What are pseudo terminals (pty/tty)?

This might be really basic question but I want to understand it thoroughly. What is a pseudo terminal? (tty/pty) Why do we need them? How they got introduced and what was the need for it? Are they ...
2
votes
3answers
1k views

Fork: Negative return value

From the fork(2) man page: RETURN VALUE On success, the PID of the child process is returned in the parent, and 0 is returned in the child. On failure, -1 is returned in the parent, no ...
5
votes
3answers
4k views

How do I kill all a user's processes using their UID

I want to kill all running processes of a particular user from either a shell script or native code on a linux system. Do I have to read the /proc directory and look for these? Any ideas? Is there a ...
0
votes
3answers
195 views

What to change to place text in the centre of the screen [closed]

The following program will clear the screen #include <stdio.h> int main() { fputs("\033[2J", stdout); return 0; } So, what should I modify/add in the above code to put a text string ...
5
votes
4answers
914 views

Does optimizing for size reduce runtime memory usage as well as binary size?

Does optimizing for size with gcc -Os only reduce the binary size of a program, or does it reduce its runtime memory usage as well? I know what exactly the results are depend on the specific code, but ...
6
votes
1answer
311 views

Why would one want to compile multiple .cpp files to the same executable?

Why would you do g++ -Wall -I/usr/local/include/thrift *.cpp -lthrift -o something instead of: g++ -Wall -I/usr/local/include/thrift -c Something.cpp -o something.o g++ -Wall ...
0
votes
1answer
3k views

how to Update gcc of OpenSuse 11.2?

I have OpenSuse 11.2 with gcc version 4.4.1. I would like to update my gcc version to 4.5.1. I have downloaded gcc-4.5-19.1.i586.rpm. When I rpm install it, it's asking for ...
0
votes
3answers
5k views

/usr/ucb/cc: language optional software package not installed

I tried to compile some C code to get object file from a shell prompt: $cc a.c But this gives me the following error: /usr/ucb/cc: language optional software package not installed How can I ...
8
votes
3answers
6k views

Man pages for standard C and C++ libraries on Fedora 14

How do I install them? At present, man fopen gives me No manual entry for fopen. I have the compilers installed and have verified that things do build without problems. Update: This is what I got ...
6
votes
4answers
10k views

make a log file

Is there any way to make a log file for maintaining some data in /var/log/ with the help of some library function or system call in c language in linux. And I also want to know the standards that we ...
3
votes
2answers
335 views

Is there a glibc API that can find the default handing application for a MIME type on linux?

I want to find the default handling application in my C program. Is there a C API with same functionality as xdg-mime query default mime-type on Linux?
6
votes
1answer
244 views

Executing a shared library

Some shared libraries provide an output when called from the command line as if they were executables. For example: $ /lib/libc.so.6 GNU C Library stable release version 2.13, by Roland McGrath et ...
4
votes
2answers
1k views

Implementing a Unix shell in C: Logging

I am currently working on implementing my own UNIX shell in C. The basis of the shell is working, you could find the source code here. Right now my next task is to implement a logging feature for the ...
8
votes
4answers
2k views

Why should a child of a vfork or fork call _exit() instead of exit()?

From the man page of vfork(): vfork() differs from fork() in that the parent is suspended until the child makes a call to execve(2) or _exit(2). The child shares all memory with its ...
11
votes
4answers
4k views

After fork(), where does the child begin its execution?

I'm trying to learn UNIX programming and came across a question regarding fork(). I understand that fork() creates an identical process of the currently running process, but where does it start? For ...
1
vote
1answer
265 views

Recording and charting boot process information in Linux

I need to write a command line tool that records the boot process information in Linux, and then renders it in a chart format (a textual chart would do). How do I programmatically obtain the this boot ...
6
votes
5answers
3k views

Develop / Debug C / C++ on Ubuntu?

What's the best IDE for developing C / C++ on Ubuntu? I tried installing Eclipse but it seems like I need the eclipse-cdt package also. The problem is there is no such package, at least for Lucid. ...
3
votes
1answer
3k views

Error when using stat, errno=2

The case is as this, I create many files, and after the file generation, I use stat to get the all files info under the directory. The purpose is to purge all the files which are old than the ...
5
votes
1answer
3k 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" # ...
8
votes
10answers
1k views

Development environment for C

Looking for ideas on setting up a convenient and productive development environment for C development. I found C editing with Vim very helpful but I would like to get a wider sampling of suggestions.