자율주행/김선영님의 리눅스 강의

리눅스 day7

Tony Lim 2020. 12. 16. 21:26
728x90

Debugging

이런식으로 debugging을 할 수 있다.

signal event : trap
trap (command | function) (SIGSPEC ...) 
command ,function = 시그널이 캐치되면 작동될 명령 or 함수 
SIGSPEC = 트랩을 설치할 시그널 or 조건

(...;) = sub shell 임으로 {...;} 그룹으로 묶어야 한다. 효율성을 위해서

예시중에 SIGTTIN ,SIGTTOU에 관해서 주의 하며 코드를 쓰라는 것이있는데 
A process cannot read from the user’s terminal while it is running as a background job. When any process in a background job tries to read from the terminal, all of the processes in the job are sent a SIGTTIN signal. The default action for this signal is to stop the process.

This is similar to SIGTTIN, but is generated when a process in a background job attempts to write to the terminal or set its modes. Again, the default action is to stop the process.

프로그램이 성공적으로 종료하면 0 , 아니면 다른 수를 보내는게 국룰이다. signal 로 종료한 경우에는 128+<signal number> 로 종료한다.

Barrier

이런식으로 기다리게 만들수있다. 예를 들면 스타할때 랜선을 뽑으면 상대방도 기다리게 만드는 그런 시스템이 있다 하셨다

error가 생겼을 때바로 빠져나오게 할려면 #!/bin/bash -e 를 해주면된다. 알아서 내부적으로 처리하고싶으면 script에 set +e 해주면 된다.

Hash table

여태까지 친 커맨드를 캐시미냥 hash table 에 저장을 해서 쓴다. 예를 들어 이 명렁어가 어디 출신인지 다 기록해줌으로 편리하다.

shopt -u huponexit = 키면 안되는 설정이다. huponexit 외에도 systemd가 도입된 이후로는 logind는 default 설정 시 세션 종료시 백그라운드 프로세스를 종료시키지 않는다.

function 안에서 shift 1 = argument를 가르키는 index를 하나 증가시켜준다. $1 부터 시작한다.

 

728x90

'자율주행 > 김선영님의 리눅스 강의' 카테고리의 다른 글

리눅스 day9  (0) 2020.12.18
리눅스 day8  (0) 2020.12.17
리눅스 day7(REGEX)  (0) 2020.12.16
리눅스 day6(bash)  (0) 2020.12.14
리눅스 day5 (file sytem)  (0) 2020.12.11