2015年2月21日土曜日

開発環境

Head First C ―頭とからだで覚えるCの基本(David Griffiths (著)、Dawn Griffiths (著) 中田 秀基(監訳)(翻訳)、木下 哲也 (翻訳)、オライリージャパン)の9章(プロセスとシステムサービス: 限界を超える)、エクササイズ(p.409)を解いてみる。

その他参考書籍

エクササイズ(p.409)

コード(BBEdit, Emacs)

#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>

int main(){
  if (execl("/sbin/", "/sbin/", NULL) == -1)
    if (execlp("ip ", "ipconfig", NULL) == -1)
      fprintf(stderr, "ipを実行できません: %s\n", strerror(errno));
}

入出力結果(Terminal)

$ crun.sh sample409 2> error.txt
clang ...
$ cat error.txt 
ipを実行できません: No such file or directory
$

0 コメント:

コメントを投稿