unix-programming

What's the best way to check if you C code has deprecated POSIX calls?

I've been working on some older C code. I found out that there are quite some POSIX calls that are now outdated and marked deprecated in the manual pages. What's the best way to check if there are still deprecated POSIX calls in your code? I'm thinking of either: special gcc warning options. some kind of lint tool detecting these call...

How to cross-platform port unix pipes?

I have a code that looks like this: uses this library #include <unistd.h> #define READ_FD 0 #define WRITE_FD 1 int m_pipe[2]; if(pipe(m_pipe) != -1) { unsigned long Id = gdk_input_add(m_pipe[READ_FD], GDK_INPUT_READ, Callback, (gpointer)this); } and it surprisingly builds on both linux(all major flavors: AS3, AS5, solaris) an...

Unix Shell Script displaying null in a text file when open in wordpad

Does anyone know how to convert Hex(00) to display Null in wordpad using Unix Shell Scripting. I have an output file which is a text file and through unix I need to convert a hex value 00 to display like a box (null) in Word pad on a particular line. Currently by using the following code I am not getting anything in my output file: h...

pthread_key_t and pthread_once_t?

Starting with pthreads, I cannot understand what is the business with pthread_key_t and pthread_once_t? Would someone explain in simple terms with examples, if possible? thanks ...

Problems with variable in Unix Shell script

Hey all. I have trouble passing a variable from inside a loop. Code: # find all output.txt that has been modified last 24h ... PROCESSED=1 find ${PROCESSED_DIR} -mtime -1 -name "output.txt" | while read i do # .. and compare those with TMP_TXT if diff $i ${TMP_TXT} > /dev/null then # If both are same EXIT search...

How can i share memory between parent-child process that free the memory automatically when they die

I know about "mmap", but as far as i know if i want to share memory allocated by a parent process and accessed it by a client process i need to create a temporary file. But this file will continue to exist if the processes die. I was educated to never leave garbage behind. Both in real life and in programming. The solution should wo...

Implementation of pthread_create on Linux

One resource on Linux mentions pthread-create being implemented with clone system call as against other unix-based platform (which implement the same in some other ways). This means that under linux two threads created from the same process using pthread_create will have different parent process ids. $ ./a.out new thread: pid 662...

pthread scheduling methods?

With no explicit scheduling, pthreads are scheduled to run by the kernel in a random manner. Are there any scheduling methods defined in the pthread library for the same such as priorities? ...

Ctrl-R to search backwards for shell commands in csh

I love this shortcut in borne shell, and want to find out if it is possible to simulate and/or have (perhaps to install an add-on or with a script) it in csh or tsch thanks ...

need to create a shell script or a command in unix which can do the following process(command will be preferred)

at the following path \\ncsusnasent02.na.jnj.com\its_diq_na_win_dev\PowerCenter\infa_shared\WCPIT_BIO_EDW\SrcFiles\DDDMD\DDD.CLI026.WK0933.DDDMR45.001.head I have one file DDD.CLI026.WK0933.DDDMR45.001.head if i open this file i get data as following(in a single line) HEADER0101IMS HEALTHDMD Weekly D DD.CLI026.WK0933.DDDMR4...

how to perform a basic arithmetics from unix csh/tcsh shell

Under windows, when I need to perform a basic calculations, I use a built-in calculator. Now I would like to find out what is the common way if you only have a shell. Thanks ...

Installing LXR on AS3 (red hat)

I want to be able to easily navigate my c++ src code on a local Linux box (red hat as3). To this end, I'm planing to in tall LXR. However, installation docs are sort of confusing. Can someone either explain or provide a link to an easy installation manual, recommended setups, etc Thanks ...

UNIX System time and User time. C-Programming

Hi I'm trying to get the system time and the user time that are consumed by a program. I'm having some trouble though as my times are always zero in milliseconds. I think I'm doing something wrong. Can you guide me in the right direction ? Both of my methods return 0 typedef struct{ struct timeval ru_utime; /* user time used */ ...

UNIX Programming. struct timeval how to print it (C-programming)

I am trying to print a value of type timeval. Actually I am able to print it, but I get the following warning: Multiple markers at this line format ‘%ld’ expects type ‘long int’, but argument 2 has type ‘struct timeval’ The program compiles and it prints the values, but I would like to know if I am doing something wrong. Thanks. ...

How do I find the MAC address programatically on IRIX?

How do I find the MAC address of a network card on IRIX? I'd rather not shell out to something that displays it and parse the output. I'm coding C. Methods that require root access are acceptable. ...

Can we start a background process using exec() giving & as an argument?

If not, how can we start a background process in C? ...

Core Dump & Segmentation Fault

Guys, I want to know the exact difference between segmentation fault and core dump. I agree that these are operating system dependent and, of course, arise due to the memory mismanagement. But please come up with some generic approaches which needs to be followed to prevent these? Sachin Chourasiya ...

how to develop the application layer of network protocol stack

hey there can anybody help me in doing this project i m nt able to do it alone =( The project is divided into phases Phase 1 : In this phase, you will develop your application layer of your network protocol stack. The application layer will provides some network services to your program like connect to a remote host, send data, and r...

awk command -to accept two variables as parameters and return a value

I have a file which has 50 rows. Each row is made up of three columns. The first two columns are the variables and this will be passed as parameters to return the 3rd column's value. for ex.. command_file.txt is the file and it contains A B 10 C D 20 E F 30 G H 50 I J 70 ... I have a script with the following command. #!/user/bin/...

How to determine where code spends a lot of time in a kernel space (system calls)

I noticed that 10% my code run is system space. However I do NOT know which system calls. I suspect, though, it is either has to do files or timestamps. Is there a tool to figure out which system calls are the culprits? Also, I want to know the frequency of (and location) of calls (and callee) . I am on AS3 thx ...