From 9d260e6fae7328d816a514130b691fbd0e9ef81d Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Fri, 3 Jul 2015 12:23:43 +0530 Subject: add/remove books --- .../Chapter24.ipynb | 126 +++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100755 C_Programming:_A_Modern_Approach_by_K.N._King/Chapter24.ipynb (limited to 'C_Programming:_A_Modern_Approach_by_K.N._King/Chapter24.ipynb') diff --git a/C_Programming:_A_Modern_Approach_by_K.N._King/Chapter24.ipynb b/C_Programming:_A_Modern_Approach_by_K.N._King/Chapter24.ipynb new file mode 100755 index 00000000..05dd8488 --- /dev/null +++ b/C_Programming:_A_Modern_Approach_by_K.N._King/Chapter24.ipynb @@ -0,0 +1,126 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:70182e1ed50aea78649f1bef2946ce2b6e335126b84963ba06fce0660ac72886" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 24: Error Handling" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example tsignal.c, Page 634" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import signal\n", + "import sys\n", + "def handler(sig,frame):\n", + " print \"Handler called for signal\",sig\n", + "print \"Installing handler for signal\", signal.SIGINT\n", + "orig_handler=signal.signal(signal.SIGINT,handler)\n", + "print \"Changing handler to SIG_IGN\"\n", + "signal.signal(signal.SIGINT,signal.SIG_IGN)\n", + "print \"Restoring original handler\"\n", + "signal.signal(signal.SIGINT,orig_handler)\n", + "print \"Program terminates normally\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Installing handler for signal 2\n", + "Changing handler to SIG_IGN\n", + "Restoring original handler\n", + "Program terminates normally\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example tsetjmp.c, Page 636" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def main():\n", + " def f1():\n", + " print \"f1 begins\"\n", + " f2()\n", + " return\n", + " print \"f1 returns\"\n", + "\n", + " def f2():\n", + " print \"f2 begins\"\n", + " #longjmp(env, 1)\n", + " setjmp=1\n", + " print \"Program terminates: longjmp called\"\n", + " return\n", + " print \"f2 returns\"\n", + "\n", + " setjmp=0\n", + " if (setjmp == 0):\n", + " print \"setjmp returned 0\"\n", + " else:\n", + " print \"Program terminates: longjmp called\"\n", + " f1()\n", + " return\n", + " print \"Program terminates normally\"\n", + " \n", + "if __name__=='__main__':\n", + " main()\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "setjmp returned 0\n", + "f1 begins\n", + "f2 begins\n", + "Program terminates: longjmp called\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file -- cgit