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

pcap and raw socket [closed]

I want to develop an application (module or user-level if possible) to create a raw socket in RHEL stealing all level-2 packets directly from kernel (without being routed or handled by other open ...
4
votes
1answer
2k views

Does free() unmap the memory of a process?

I am running a C program on Linux 2.6.16 kernel. I do not think there are memory leaks in my program however the memory consumption for the program remains stable after certain operations and does not ...
7
votes
2answers
7k views

How to compile a c program without leaving the editor? [duplicate]

I am using vim editor on Linux mint. I want to know if there is any way to compile c program without leaving the editor.
2
votes
4answers
605 views

/usr/bin/which returns cryptic error “which: no ls in ((null))”

I am writing a simple shell program. When I use /usr/bin/which with my shell in mac osx and ubuntu, it acts normally. When I use the exact same command on Red Hat Enterprise Linux Client release 6.3 ...
157
votes
4answers
55k 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 ...
3
votes
1answer
612 views

Confused about ident

I inherited a bunch of files that begin with the following statement at the top Ident:/some/path/to/a/file Ident seems to be related to C coding and make files but I am not really sure. None of the ...
-2
votes
1answer
792 views

Difference Between #include “file.h” and #include <file.h> [closed]

What is the difference between the #include "file.h" and the #include <file.h>? Surely they mean the exact same thing, because I have a file that has something like this: #include ...
12
votes
2answers
3k views

Why can't I run this C program?

I'm trying to run my first "process" program, but I get the following error : ./fork.c: line 4: syntax error near unexpected token `(' ./fork.c: line 4: `int main()' I'm pretty sure that the code ...
4
votes
1answer
1k views

How to create a fake device file that accepts input from a C program?

I want to create a C program that accepts input from a joypad (/dev/input/js0), processes it, and then sends it to a fake device file (character or block) labeled as a keyboard (oh, and what is the ...
0
votes
1answer
182 views

Bash shell with problematic outcomes under Linux (C) [closed]

Following my previous post, I still have one annoying bug that won't leave . I wrote a simulator for the bash command under Linux. When I run my code in a single run, with the these commands: ls ...
0
votes
1answer
363 views

Redirecting output of program reading from stdin

When I want to redirect an output of a.out program I will use ./a.out > output.txt This doesn't work when the program reads something from stdin. How would you redirect output in this case? I ...
5
votes
1answer
2k views

/dev/tcp not present in Linux

I am porting C/pro*c code from UNIX to Linux. The code is: #define __NFDBIT (8 * sizeof(unsigned long)) #define __FD_SETSIZ 1024 #define __FDSET_LONG (__FD_SETSIZ/__NFDBIT) typedef struct ...
1
vote
1answer
610 views

How to preload my .so everytime an application executes?

I've successfully used a hook under linux with this article: http://hackerboss.com/overriding-system-functions-for-fun-and-profit/ Now I want to make my .so file load every time espeak loads up. No ...
7
votes
2answers
4k 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
282 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
415 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
443 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
144 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
82 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
2k 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
29k 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 ...
5
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
291 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
319 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
5k 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
341 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
639 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
4k 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
3k 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
384 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
355 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
192 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
4k 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 ...
3
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 ...
18
votes
3answers
12k 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
5k 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
215 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
1k 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
320 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 ...
9
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 ...