diff --git a/Changelog.md b/Changelog.md
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,3 +1,7 @@
+### 1.2.2
+
+- Returning a special error code (*2*) on exception *ServiceHookInterrupt*.
+
 ### 1.2.1
 
 - Bugfix: put *unsigned* integers in event channels (important for *eventfd*).
diff --git a/NgxExport.hs b/NgxExport.hs
--- a/NgxExport.hs
+++ b/NgxExport.hs
@@ -362,6 +362,12 @@
         poke (castPtr p) n
         poke (plusPtr p $ alignment x) s
 
+data ServiceHookInterrupt = ServiceHookInterrupt
+
+instance Exception ServiceHookInterrupt
+instance Show ServiceHookInterrupt where
+    show = const "Service was interrupted by a service hook"
+
 safeMallocBytes :: Int -> IO (Ptr a)
 safeMallocBytes =
     flip catchIOError (const $ return nullPtr) . mallocBytes
@@ -464,9 +470,12 @@
     IO (L.ByteString, (CUInt, Bool))
 safeYYHandler = handle $ \e ->
     return (C8L.pack $ show e,
-            (1, case asyncExceptionFromException e of
-                    Nothing -> False
-                    Just ae -> ae == ThreadKilled
+            (case fromException e of
+                Just ServiceHookInterrupt -> 2
+                _ -> 1
+            ,case asyncExceptionFromException e of
+                Just ThreadKilled -> True
+                _ -> False
             )
            )
 {-# INLINE safeYYHandler #-}
@@ -739,12 +748,6 @@
     StablePtr (Async ()) -> IO ()
 ngxExportTerminateTask = deRefStablePtr >=>
     cancel
-
-data ServiceHookInterrupt = ServiceHookInterrupt
-
-instance Exception ServiceHookInterrupt
-instance Show ServiceHookInterrupt where
-    show = const "Service was interrupted by a service hook"
 
 foreign export ccall ngxExportServiceHookInterrupt ::
     StablePtr (Async ()) -> IO ()
diff --git a/ngx-export.cabal b/ngx-export.cabal
--- a/ngx-export.cabal
+++ b/ngx-export.cabal
@@ -1,5 +1,5 @@
 name:                       ngx-export
-version:                    1.2.1
+version:                    1.2.2
 synopsis:                   Helper module for Nginx haskell module
 description:                Helper module for
         <http://github.com/lyokha/nginx-haskell-module Nginx haskell module>
