2014年11月10日月曜日

開発環境

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

その他参考書籍

エクササイズ(p.409)

コード(BBEdit, Emacs)

sample409.c

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

int main(int argc, char *argv[])
{
  if (execl("/sbin/ifconfig", "/sbin/ifconfig", NULL))
      if (execlp("ipconfig", "ipconfig", NULL)) {
        fprintf(stderr, "ipconfigを実行できません: %s", strerror(errno));
        return 1;
      }
  return 0;
}

Makefile

P=
CC=cc
CFLAGS=-g -Wall # -O3
SRC=
OBJ=
LDLIBS=

$(P): $(OBJ)
 $(CC) $(CFLAGS) $(LDLIBS) $(OBJ) -o $@


入出力結果(Terminal)

$ make sample409
cc -g -Wall     sample409.c   -o sample409
$ ./sample409
... 省略 ...
$ echo $?
0
$

0 コメント:

コメントを投稿