2016-02-27 41 views
-3
read(fileno(stdin), passwd, 1024); 
if(strcmp(passwd, real_password) == 0) { 
    printf("\n\nWelcome back :)\n\n~$ "); 
    fflush(stdout); 
    system("/bin/bash -p"); 

所以我有這個程序,我想知道系統(「/ bin/bash -p」)調用在程序中做什麼?系統在以下程序中調用的是什麼?

回答

0

它使用參數-p執行bash。根據代碼,合格的路徑是/bin/bash

檢查的system()裁判:

說明

The system() library function uses fork(2) to create a child process 
    that executes the shell command specified in command using execl(3) 
    as follows: 

     execl("/bin/sh", "sh", "-c", command, (char *) 0); 

    system() returns after the command has been completed. 

-p參數,根據bash REF:

-p選項改變輸出格式達到POSIX

的規定
+0

和那會做什麼。使用參數執行bash -p – follower

+0

這就是'system()'@ @follower的作用。希望有所幫助。 – gsamaras

+0

我只是不明白這個調用的意義是什麼 – follower

相關問題