unix

mktime and tm_isdst

◇◆丶佛笑我妖孽 提交于 2020-01-21 01:15:07
问题 I saw a lot of different views so thought of asking here. I read man mktime : (A positive or zero value for tm_isdst causes mktime() to presume initially that summer time (for example, Daylight Saving Time) is or is not in effect for the specified time, respectively. A negative value for tm_isdst causes the mktime() function to attempt to divine whether summer time is in effect for the specified time. My question is, shouldn't tm_isdst be kept as -1 to let the system decide if its dst or not

Why zombie processes exist?

有些话、适合烂在心里 提交于 2020-01-20 22:05:27
问题 Wikipedia says "A child process that terminates but is never waited on by its parent becomes a zombie process." I run this program: #include <stdio.h> #include <unistd.h> #include <stdlib.h> int main() { pid_t pid, ppid; printf("Hello World1\n"); pid=fork(); if(pid==0) { exit(0); } else { while(1) { printf("I am the parent\n"); printf("The PID of parent is %d\n",getpid()); printf("The PID of parent of parent is %d\n",getppid()); sleep(2); } } } This creates a zombie process, but I can't

Unix版本演进 SVR4

北慕城南 提交于 2020-01-20 20:37:07
1969 Kenneth Thompson(和 Dennis Ritchie都参加过交互方式分时系统Multics的设计)在小型计算机上开发UNIX系统,后于1970年投入运行。 1973 Dennis Ritchie开发出C语言,用来改写原理用汇编语言编写的UNIX,由此产生了 UNIX Version V 。 1974 Kenneth Thompson和Dennis Ritchie合写的“The UNIX Time-sharing System"在Communication of ACM((Association for Computing Machinery,国际计算机协会)上发表,正式向外界披露了UNIX系统。 1978年,UNIX Version VI发表,随后又于1979年用于VAX-11超级小型机。以后,不断地出现各种新的版本。 美国电话电报公司分别于 1981 年和 1983 年发表AT&T UNIX SystemII和 UNIX SystemV 。 美国加州大学伯克莱分校也先后发表了UNIX的版本BSD4.1,BSD4.2和BSD4.3。 SVR4 (UNIX System V Release4)是AT&T在 1989 年首次发行的;SVR4集成SVR3,4BSD,SunOS,以及XENIX的一些特性,还添加了一些新功能,如实时调度,Korn shell

Multiple fork() Concurrency

萝らか妹 提交于 2020-01-20 19:42:06
问题 How do you use the fork() command in such a way that you can spawn 10 processes and have them do a small task concurrently. Concurrent is the operative word, many places that show how to use fork only use one call to fork() in their demos. I thought you would use some kind of for loop but i tried and it seems in my tests that the fork()'s are spawning a new process, doing work, then spawning a new process. So they appear to be running sequentially but how can I fork concurrently and have 10

How to find a user's home directory on linux or unix?

六眼飞鱼酱① 提交于 2020-01-20 13:32:14
问题 How do I find the home directory of an arbitrary user from within Grails? On Linux it's often /home/user. However, on some OS's, like OpenSolaris for example, the path is /export/home/user. 回答1: For UNIX-Like systems you might want to execute " echo ~username " using the shell (so use Runtime.exec() to run {"/bin/sh", "-c", "echo ~username"} ). 回答2: Normally you use the statement String userHome = System.getProperty( "user.home" ); to get the home directory of the user on any platform. See

How to find a user's home directory on linux or unix?

有些话、适合烂在心里 提交于 2020-01-20 13:31:46
问题 How do I find the home directory of an arbitrary user from within Grails? On Linux it's often /home/user. However, on some OS's, like OpenSolaris for example, the path is /export/home/user. 回答1: For UNIX-Like systems you might want to execute " echo ~username " using the shell (so use Runtime.exec() to run {"/bin/sh", "-c", "echo ~username"} ). 回答2: Normally you use the statement String userHome = System.getProperty( "user.home" ); to get the home directory of the user on any platform. See

Line completion with custom commands

与世无争的帅哥 提交于 2020-01-20 13:30:47
问题 my Python program can be launched with a range of different options (or subcommands) like: $ myProgram doSomething $ myProgram doSomethingElse $ myProgram nowDoSomethingDifferent I want it to use auto-completion with so that if i type "myProgram d" it returns "myProgram doSomething" and if i type "myProgram n" it renders "myProgram nowDoSomethingDifferent". This is similar to the average use of the module rlcompleter , but it does not pick possible completion options from the filesystem (or

grep -f maximum number of patterns?

↘锁芯ラ 提交于 2020-01-20 05:07:06
问题 I'd like to use grep on a text file with -f to match a long list (10,000) of patterns. Turns out that grep doesn't like this (who, knew?). After a day, it didn't produce anything. Smaller lists work almost instantaneously. I was thinking I might split my long list up and do it a few times. Any idea what a good maximum length for the pattern list might be? Also, I'm rather new with unix. Alternative approaches are welcome. The list of patterns, or search terms, are in a plaintext file, one per

grep -f maximum number of patterns?

倖福魔咒の 提交于 2020-01-20 05:05:26
问题 I'd like to use grep on a text file with -f to match a long list (10,000) of patterns. Turns out that grep doesn't like this (who, knew?). After a day, it didn't produce anything. Smaller lists work almost instantaneously. I was thinking I might split my long list up and do it a few times. Any idea what a good maximum length for the pattern list might be? Also, I'm rather new with unix. Alternative approaches are welcome. The list of patterns, or search terms, are in a plaintext file, one per

How do I determine if a terminal is color-capable?

99封情书 提交于 2020-01-20 01:35:45
问题 I would like to change a program to automatically detect whether a terminal is color-capable or not, so when I run said program from within a non-color capable terminal (say M-x shell in (X)Emacs), color is automatically turned off. I don't want to hardcode the program to detect TERM={emacs,dumb}. I am thinking that termcap/terminfo should be able to help with this, but so far I've only managed to cobble together this (n)curses-using snippet of code, which fails badly when it can't find the