Description:
Q&A for people programming under Unix.
|
|
|
daemon openlog() question...
|
| |
How can openlog() in a daemon write to some file if fd 0, 1, and 2 get redirected to /dev/null and ther rest the fds are closed.
|
|
permission denied on bind when restart with execl
|
| |
Then in my application when alert() happen a signal handler start. The signal handler should restart application, i do it with execl() function: void onTimeoutHandler() { // argv1 & argv2 are two global var that contain argv[1] e argv[2] execl("application", argv1, argv2); ...The apps really restart but the problem is that it stop itself on bind... more »
|
|
flex & bison: parse command line arguments?
|
| |
Is it possible to parse command line arguments with the help of flex and bison? If so, how is it done? I suspect that it may be simply a matter of tweaking flex into processing arrays of null-terminated strings instead of stdin but I can't find a single reference. So, can anyone help? Thanks in advance,... more »
|
|
list all file lock in a file
|
| |
Hi. I read the info manual of glibc for the advisory record lock using fcntl(2) function on my Linux system. It says that if the specific part of the file has more than one lock, fcntl(fd, F_GETLK, &lock) will only return information about one of them. After simple experiment, I found that fcntl(, F_GETLK, ) returns the... more »
|
|
How to fast close socket?
|
| |
Hi, I noticed that after my program exits, there still an entry when I run 'netstat -np', the socket is a TCP socket bind() into a given port, after the exit, seems the state of the connection show TERM-WAIT(or something else) for a few seconds. This bothers me because I want to restart the program very quickly,... more »
|
|
output Nth line of matching string using grep
|
| |
hi, i need to grep in such a way that, i need to print a third line (or Nth line) after the matching string. For example in the above string matching string is ABC and i need to print "This Line". for the following Text my grep output should be ABC dsfsf safdaf This Line ABC dsfsf safdaf One more Line... more »
|
|
getnameinfo() buffer overflow!
|
| |
...Hi, Below program can show that the getnameinfo() will grab one more byte than given, I am running that program in Linux. I give the getnameinfo() that the host name buffer length of 7, but it write a '\0' to the eight-th character of the buffer. Anything wrong? main() { struct sockaddr_in sa; /* input */... more »
|
|
minimum # of open file limit?
|
| |
Hi. As long as I understood, when main() is started, thet C start-up code opens three files (stdin, stdout, and stderr). To verify this, consider this small program (a.out): int main(void) { return 0; ...When I limit the maximum # of open file to 3 using ulimit, the program failed to run: $ ulimit -n 3... more »
|
|
|