2016-02-27 39 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

相关问题