프로세스 실행 후 종료 확인 코드

프로그래밍/java 2022. 2. 17. 22:18
반응형

java에서 process 실행 후 결과 값을 stream 으로 계속 읽어 들일때 process 가 종료 되면

readline 등의 메소드가 block 이 걸릴수 있다.

이때 process를 체크하는 thread를 따로 생성 후 모니터링 하여 종료를 체크 하여 필요한 동작을 처리 한다.

https://beradrian.wordpress.com/2008/11/03/detecting-process-exit-in-java/

 

Detecting process exit in Java

If you develop a more complex system, the chances of being a heterogeneous are pretty big. So if you develop a system in Java, but you have to integrate all ready build parts with other technology,…

beradrian.wordpress.com

 

    public void run() {
        try {
            // wait for the process to finish
            process.waitFor();
            // invokes the listeners
            for (ProcessListener listener : listeners) {
                listener.processFinished(process);
            }
        } catch (InterruptedException e) {
        }
    }
반응형
:

javadoc "error: package android.os does not exist" 에러가 날때

프로그래밍/java 2022. 1. 26. 22:58
반응형

javadoc 실행시 참조하는 패키지를 찾지 못할때 발생하는 에러로 javadoc 버전에 영향을 받음

최신 버전으로 사용할 경우 에러 발생함

 

/usr/lib/jvm/java-16-openjdk-amd64/bin/javadoc   => 에러 발생

error: package android.os does not exist
import android.os.RemoteException;

......

25 errors

 

패키지 경로를 추가하는 등의 방법으로 해결가능해 보이지만 수정에 한계가 있어 보임

꼭 javadoc 버전을 정해서 사용해야 되는 것이 아니라면 낮은 버전의 javadoc 사용으로 해결됨

/usr/lib/jvm/java-8-openjdk-amd64/bin/javadoc => 에러없이 문서가 만들어짐

                                                                                      갯수는 동일 하나 에러가 아닌 warning으로 처리됨

 

error: package android.os does not exist
import android.os.RemoteException;

......

25 warnings

반응형
:

Ubuntu 편하게 쓰기 - 긴명령 줄 불러오기 : Pet

OS/linux 2022. 1. 18. 22:23
반응형

pet : CLI Snippet Manager

https://github.com/knqyf263/pet

 

GitHub - knqyf263/pet: Simple command-line snippet manager, written in Go.

Simple command-line snippet manager, written in Go. - GitHub - knqyf263/pet: Simple command-line snippet manager, written in Go.

github.com

 

fzf 설치(명령 리스트 볼때 사용 되며, 그외 여러 명령 과 결합하여 사용됨)

https://github.com/junegunn/fzf

 

GitHub - junegunn/fzf: A command-line fuzzy finder

:cherry_blossom: A command-line fuzzy finder. Contribute to junegunn/fzf development by creating an account on GitHub.

github.com

$ sudo apt-get install fzf

 

pet 설치

$ wget https://github.com/knqyf263/pet/releases/download/v0.3.6/pet_0.3.6_linux_amd64.deb
$ dpkg -i pet_0.3.6_linux_amd64.deb

 

pet 실행

$ pet
pet - Simple command-line snippet manager.

Usage:
  pet [command]

Available Commands:
  configure   Edit config file
  edit        Edit snippet file
  exec        Run the selected commands
  help        Help about any command
  list        Show all snippets
  new         Create a new snippet
  search      Search snippets
  sync        Sync snippets
  version     Print the version number

Flags:
      --config string   config file (default is $HOME/.config/pet/config.toml)
      --debug           debug mode
  -h, --help            help for pet

Use "pet [command] --help" for more information about a command.

 

ctrl-s 키로 pet search 실행 설정하기

$ cat .zshrc
function pet-select() {
  BUFFER=$(pet search --query "$LBUFFER")
  CURSOR=$#BUFFER
  zle redisplay
}
zle -N pet-select
stty -ixon
bindkey '^s' pet-select

명령 추가 및 변경 - 설정 파일 변경(명령 옵션 사용하기 귀찮을때)

텍스트 에디터로 변경 후 저장

$ cat ~/.config/pet/snippet.toml
[[snippets]]
  description = "git show file list of commit"
  command = "git diff-tree --no-commit-id --name-only -r <revision>"
  output = ""

[[snippets]]
  description = "find files that dont contain string pattern"
  command = "egrep -riL \"copyright\" dir"
  output = ""

[[snippets]]
  description = "git find files created after date"
  command = "git log --pretty=oneline --name-status --since \"26 jul 2018\" | grep ^A"
  output = ""

[[snippets]]
  description = "gnome-control-center"
  command = "sudo env XDG_CURRENT_DESKTOP=GNOME gnome-control-center"
  output = ""

[[snippets]]
  description = "check open file before umount "
  command = "lsof +f -- /home/builder/hdd_home"
  output = ""

[[snippets]]
  description = "ssh to ssh client"
  command = "ssh builder@`echo $SSH_CLIENT | awk '{ print $1}'`"
  output = ""

 

 

 

반응형
: