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.
-1
votes
0answers
24 views
Explain how doit() function works in rshd.c [migrated]
I want to know how rsh runs any command. I am using netkit-rsh-0.17 package. My OS is centOS.
In rshd directory, rshd.c performs the task to run any command on server.
In this file, doit() is the ...
-1
votes
3answers
70 views
telnet implementation using C [closed]
The program in general is I want to implement telnet program.
On the client side user send its logging name and password, and if it is correct he starts to send commands to the server
On the Server ...
0
votes
2answers
25 views
Which process updates /proc/scsi/scsi?
I wrote C that displays info about my hardware on ubuntu. Now I wonder how I can make it more flexible such as querying the hardware directly instead of the file the os updates. So I think I can look ...
0
votes
0answers
42 views
+50
mod_rewrite: undefined symbol: lstat error
I compiled the mod rewrite for apache (version 1.3.0) however, when I try to run the server I have this error about mod_rewrite:
Syntax error on line 27 of /home/myuser/apache/etc/httpd.conf:
Cannot ...
3
votes
1answer
54 views
Send log messages to a different location
I want to send messages from C program and from Perl script to a file (for example, /var/log/my_log). I don't have access to the syslog daemon configuration, so I think in launch a differente syslog ...
0
votes
0answers
16 views
Getting the abstract syntax tree of a C program with GCC [migrated]
How to get abstract syntax tree of a C program with GCC?
I'm trying to automatically insert OpenMP pragmas to the input C program. I need to analyze nested for loops to find dependencies so that I ...
-3
votes
2answers
54 views
Which Linux distro/mode offers lowest interference when running your own applications?
I'm interested in a Linux distro to build C projects and test their behavior in a very predictable and controlled environment. I'm especially concerned about letting the scheduler deal as much as ...
0
votes
1answer
61 views
Having trouble executing a compiled C program
I am running an Ubuntu v10.04 through VirtualBox. To test the persistence of files I create in the virtual machine, I wrote a very basic C program. When I shutdown the virtual machine and restart it, ...
0
votes
0answers
63 views
'dereferencing pointer to incomplete type' in compiling FreeBSD 4.2 custom system call - FreeBSD [closed]
I already posted this question on Stack overflow, but no luck there:
http://stackoverflow.com/questions/14784525/dereferencing-pointer-to-incomplete-type-in-compiling-freebsd-custom-system-caF
I am ...
-1
votes
2answers
80 views
Do BSD sockets give better performance than others eg. POSIX and other? [closed]
I am searching cross-platform techniques to write client-server applications on Mac. I used BSD sockets, Cocoa APIs but I need to know which would be better at performance.
2
votes
3answers
82 views
Linux GCC compiler options
I have recently started using Linux as a tool for programing. In my book, I have seen that the GCC is used with 2 options: -g and -o. Now, I know that -o is to set a filename, but what is the purpose ...
0
votes
0answers
47 views
explain the program in advanceunix? [closed]
I understand the fork concept. I'm trying to solve the following problem.
I have to write a program that forks. The parent process gets a valid Unix command from the user, and passes it to the child. ...
1
vote
0answers
79 views
Conky - string formatting
I have conky the record:
${color lightblue} Down: ${downspeed wlan0} Up: ${upspeed wlan0}
Conky prints link speed, but the text moves:
Down: OB Up: OB
Down: 60B Up: 60B
Down: 148B Up: 148B
...
0
votes
1answer
131 views
How do I write a login daemon?
There are many guides to the steps for correctly launching a daemon process, such as Stevens' chapter in Advanced Programming in the UNIX Environment. There is less agreement on what steps should be ...
1
vote
1answer
80 views
Linux kernel 3.2 syscalls
Just trying to get the assembler instructions for <__execve> of the code below because i want to build the shell spawn opcode list:
#include <stdio.h>
int main()
{
char *happy[2];
...
2
votes
2answers
100 views
USB Driver Compilation Error
I'm currently trying to compile a Linux USB UART driver, which is provided here:
http://www.exar.com/connectivity/uart-and-bridging-solutions/usb-uarts/xr21v1410
The driver consists of 2 header files ...
1
vote
1answer
51 views
How do I keep 'indent' from moving curly braces to the next line?
I have several empty inline function definitions in C++ like so:
class C
{
void foo(){}
void bar(){}
};
now if I run indent -st -i4 -nut test.cc in order to just fix the indentation I get
...
2
votes
0answers
57 views
Command-line file reader (like “less”) that can tell the line where the user stopped reading
[Context] I'm developing a little app, as a hobby to learn ncurses, that catalogs and lists and searches within a set of documents (for now, they are the HOWTOs from TLDP).
The most tricky part of ...
1
vote
1answer
270 views
Calculating total CPU system usage in C
I found this answer on StackOverflow for calculating total CPU usage: http://stackoverflow.com/questions/1420426/calculating-cpu-usage-of-a-process-in-linux/4497769#4497769
But how do I calculate ...
1
vote
1answer
67 views
Writing a service in C: How to pass and process arguments to running service?
I want to write a service in C.
While this service is running in background and processing some information I need to grab the results from this service from other applications or from command line.
...
3
votes
1answer
106 views
IP_TRANSPARENT missing from glibc headers
I'm trying to use the IP_TRANSPARENT declaration. I am using debian 6.0.5. IP_TRANSPARENT is only defined in linux/in.h however it conflicts with netinet/in.h.
In centos for example, IP_TRANSPARENT is ...
2
votes
2answers
198 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
0answers
93 views
Having problems with script and redirecting input to stdin [closed]
EDIT: found mistake, it was actually bug in my program, I had > instead of >= in my for loop that reads coefficients.
I'm fairly new to linux, and I need help with bash scripting.
I have C program, ...
1
vote
2answers
124 views
How to adjust time command to measure a program elapsed time
I'm trying to get the time that my program takes to finish (aka elapsed time) so I'm using the common time.
What I get by doing this is 3 measurements: user, system and total. This is fine but I ...
0
votes
1answer
180 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 ...
3
votes
1answer
190 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 ...
-2
votes
1answer
56 views
Can I add content to client file from server using C programming? [closed]
e.g I want to add
127.0.0.1 www.google.com
to the /etc/hosts file from server using C programming language.
4
votes
2answers
347 views
How to compile a c program without leaving the editor?
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
160 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 ...
44
votes
4answers
10k 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
111 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
139 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 ...
18
votes
1answer
361 views
How to get started writing drivers?
I have a throw-away cheap laptop I'd like to twiddle around, a Thinkpad SL 500.
What bothers me are two leds, the one for wireless connectivity, and the one for hibernation, which don't light up at ...
12
votes
2answers
2k 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 ...
3
votes
1answer
360 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
165 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
195 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 ...
2
votes
1answer
542 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
266 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 ...
4
votes
2answers
335 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
133 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
158 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
102 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
68 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
66 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 ...
1
vote
1answer
379 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 ...
1
vote
1answer
5k 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
764 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 ...
2
votes
1answer
1k 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 ...
4
votes
1answer
429 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 ...