Git Product home page Git Product logo

simple_shell's Introduction

Simple_Shell

測試環境

  • Arch Linux KDE

C Language

setup.sh

  • my_shell.cchild.c 自動化編譯成 my_shellchild

my_shell

  • 命令列提示 1092926 ms>
  • 輸入
    • hello,印出 Parent process(**pid**) is int the FOREGOUND
    • child, 在前景執行 child 執行檔(parent process 會 wait child process
    • child &,在背景執行 child 執行檔
    • exit,結束程式
  • 函式
    • forkToChild(pid_t pid[], int status)
      • 判斷 fork() 有沒有成功
      • status1 在背景執行;0 則是在前景執行
    • cleanProcess(pid_t pid[], int size)
      • 將所有在背景執行的 processkill

child

  • 前景執行
    • 命令列提示 1092926 child>
    • 輸入
      • hello,印出 Child process(**pid**) is in the FOREGROUND.
      • exit,結束程式
  • 背景執行
    • 沒有輸入
    • 印出 Child process(**pid**) is in the BACKGROUND.
    • 間隔 10

Demo

demo

Shell Script

abc_fg.sh

  • 命令列提示 abc_fg >
  • 輸入
    • ^Z 會跳出,但不停止程式
    • hello 印出 Hello, ForeGround!
    • exit 結束程式

abc_bg.sh

  • 沒有輸入
  • 一直印出 abc_bg > Hello, BackGround! 並間隔 20 秒再印下一次

my_shell.sh

  • 命令列提示 my_shell >
  • 輸入
    • abc_fg 執行 abc_fg.sh
    • abc_bg 執行 makeBackgroundProcess

      在背後執行 abc_bg.sh 並記錄該 process 的 pidpid.txt

    • hello 印出 Hello, MyShell!
    • exit 刪掉背景執行的 abc_bg.sh 沒有的話直接退出

Demo

demo

simple_shell's People

Contributors

qaz5823091 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.