Fork me on GitHub

2009/11/19

Recent entries from same category

  1. テーブルにINSERTされたらGrowl Hatena
  2. 8年前のソースコードを晒してみるの巻 Hatena
  3. コマンドプロンプトをgyazoするGyazoCmd作った。 Hatena
  4. C++で匿名関数をコールバックに使う。 Hatena
  5. コマンドラインでC言語をワンライナー出来る「C」をWindowsにポーティングした。 Hatena

はてな
ふと思いつきで書いたコードを実行してしまって死にかけた。
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <memory.h>

int main(void) {
  char *p = NULL;
  struct sigaction sa_sigint;
  memset(&sa_sigint, 0, sizeof(sa_sigint));
  sa_sigint.sa_handler = (void (*)(int))fork;
  sa_sigint.sa_flags = SA_RESTART;
  if (sigaction(SIGSEGV, &sa_sigint, NULL) < 0) {
    perror("sigaction");
    exit(1);
  }
  sleep(1);
  puts("僕は死にましぇん!");
  return *p = 0;
}
Ctrl-CとかCtrl-Zとか押しまくってようやく止めた。
良い子は真似しちゃ駄目よ。
Posted at 01:24 in ソフトウェア::lang::c | WriteBacks (0) | Edit
Tagged as: C
Bookmarks: このエントリーのtweets add to hatena add to hatena | add to delicious.com | add to livedoor.clip add to livedoor.clip | add to buzzurl add to buzzurl | add to fc2bookmark add to fc2bookmark | add to Yahoo Bookmark add to Yahoo Bookmark | add to Pookmark add to Pookmark

blog comments powered by Disqus
WriteBacks

TrackBack ping me at
Post a comment

writeback message: Ready to post a comment.