#include<stdio.h>
#include<signal.h>
void handler(int signo)
{
printf("Into handler\n");
while(1);
}
int main()
{
struct sigaction act;
act.sa_handler = handler;
act.sa_flags = 0;
sigemptyset(& act.sa_mask);
sigaction(SIGINT, &act, NULL);
while(1);
return 0;
}
After catching the KeyboardInterrupt on...
Signals seem to be one of those areas that should be conceptually simple and easy to explain but I have never come across one source that is both comprehensive, lucidly written, and up to date. In part this seems to be because of historical cruft, lots of exceptions to rules, different programming standards, the confusion threads throw ...
I have a directory and a bunch of sub-directories like this:
- directory1 (sub-dir1, sub-dir2, sub-dir3, sub-dir4, sub-dir5...........and so on, hundreds of them...)
How do I find out what is average size of the sub-directories?
And how do I find what is the maximum size of the sub-directories?
All using Unix commands...
Thanks.
...
So this cant be too difficult, I need a feed date/time converted into a unix timestamp in PHP.
from "2010-04-13T10:00:00.000-04:00" -> Unix
I have been trying all sorts of weird things with date() and strtotime() with no luck. Thank you!
...
I'm converting some code written for a linux system to a windows system. I'm using C++ for my windows system and wanted to know the equivalent of the function inet_aton.
...
What's the popular tool people use in Unix to parse/analyze log files? Doing counting, find unique, select/copy certain line which have certain patterns. Please advise some tools or some keyword. Since I believe there must be similar questions asked before, but I don't any idea about the keywords. Thanks.
...
I am trying to implement the odd-even transposition sorting algorithm in c with multi-threading. The program will receive a file with a line of integers that need to be correctly sorted. I have created the array that the program will work with and I am reading in the data correctly. Although, I am not quite sure how to create the threads...
Someone told me to do this in order to keep track of latest people hitting my server:
tail -f access.log
However, this shows all the "includes", including the JS file, the graphics, etc. What if I just want to see the pages that people hit? How do I filter that using tail -f?
...
The select() and pselect() system calls modify their arguments (the 'fd_set *' arguments), so the input value tells the system which file descriptors to check and the return values tell the programmer which file descriptors are currently usable.
If you are going to call them repeatedly for the same set of file descriptors, you need to e...
I'm trying to comprehend the Unix file system on my OSX. I'm following wikipedia Filesystem Hierarchy Standard.
I understand when I install ruby gems I must use the command sudo gem install but if I omit sudo, problems may occur.
Where are gems installed within the file system when I omit sudo?
How can I delete these gems?
A Fun side ...
something like:
scp -r all_directories_in_current_directory fenix@xxxxx:~/data
anyone can give me a clue?
...
Hello,
Can you please suggest me the syntax for doing floating point comparison in shell script. I am using bash.
I would ideally like to use as part of if statement
here is a small code snippet :
key1="12.3"
result="12.2"
if (( $result <= $key1 ))
then
# some code here
fi
thanks
Kiran
...
In my C program I want to know if my executable is run in foreground like this
$./a.out
or like this
$./a.out &
...
I have defined a function in vim to properly indent folds. Ie so they look like this:
Unfolded
this is text
also text
indented text
indented text
not indented text
folded with default function
this is text
also text
+-- 2 lines: indented text ----------------------------
not indented text
folded with my new function
th...
I want to grep for the string "-X" in a file but it's confusing this as a command line argument.
I've tried
grep "-X"
grep \-X
grep '-X'
...
The actual situation is a bit complicated, but the issue I'm running into is that I have an echo command within an eval command. Like so:
$ eval echo 'keep my spacing'
keep my spacing
$ echo 'keep my spacing'
keep my spacing
I was wondering how I could keep eval from stripping my spacing so that the first command pri...
I'm trying to use unix cut to remove the first two fields per line. I have input lines of of the form
(token)(whitespace)(token)(lots of text)
The problem is that there exit n tokens per line, so I can't do something like this
cut -f3,4,5,6,7,8,9
is there a way to tell cut to take everything except the specified fields
...
I'm using find for a task and I noticed that when I do something like this:
find `pwd` -name "file.ext" -exec echo $(dirname {}) \;
it will give you dots only for each match. When you s/dirname/basename in that command you get the full pathnames. Am I screwing something up here or is this expected behavior? I'm used to basename givin...
Hello,
In addition to my previous query concerning multi-threading in shell scripting
I am curious if its possible to have multiple progress bar.
Here is a code snippet of my expected result :
Output : 1 of 100 Files Completed # Thread1
Output : 10 of 45 files Completed # Thread 2
The lines are updated showing the progre...
When reading about pipes in Advanced Programming in the UNIX Environment, I noticed that after a fork that the parent can close() the read end of a pipe and it doesn't close the read end for the child. When a process forks, does its file descriptors get retained? What I mean by this is that before the fork the pipe read file descriptor...