| Edit | Rename | Upload | Download | Back to Top |
ObjectMemory class>>registerObject: anObject withEngineFor: purposeString
That method allows you to register objects as handlers. Typically, one uses a semaphore which signals Smalltalk when the signal of interest arrives. Other messages of interest:
registrationNames "Answer an Array of the registration purposes supported by this VM." objectRegisteredWithEngineFor: purposeString "Answer the object registered with the engine for the purpose specified by purposeString, or nil if none. The set of purpose names is answered by registrationNames. The primitive fails informatively. If the purpose argument does not encode an ASCII string the failure code is #'bad argument'. If the purpose argument names an unknown purpose the failure code is #'no match'."
The comments in the first method listed above are quite instructive, and I've copied them here:
Register the first argument, an arbitrary object, to be used for a purpose specified by the second argument, a ByteString or ByteArray in ASCII encoding. The list of purposes and appropriate objects is: ScavengeSemaphore; a semaphore to signal after each scavenge and on Unix platforms most of the following: SIGCHLD; a semaphore signalled when the VM process receives the SIGCHLD signal SIGCONT; a semaphore signalled when the VM process receives the SIGCONT signal SIGHUP; a semaphore signalled when the VM process receives the SIGHUP signal SIGINT; a semaphore signalled when the VM process receives the SIGINT signal SIGIO; a semaphore signalled when the VM process receives the SIGIO signal (a.k.a. SIGPOLL) SIGPIPE; a semaphore signalled when the VM process receives the SIGPIPE signal SIGQUIT; a semaphore signalled when the VM process receives the SIGQUIT signal SIGTERM; a semaphore signalled when the VM process receives the SIGTERM signal SIGURG; a semaphore signalled when the VM process receives the SIGURG signal SIGUSR1; a semaphore signalled when the VM process receives the SIGUSR1 signal SIGUSR2; a semaphore signalled when the VM process receives the SIGUSR2 signal The definitive list of the purposes is answered by ObjectMemory class>>#registrationNames, and is more dependable than this comment. The primitive fails informatively. If the purpose argument does not encode an ASCII string the failure code is #'bad argument'. If the purpose argument names an unknown purpose the failure code is #'no match'. If the object is not a valid type for the purpose the failure code is #'inappropriate operation'.
The code example I've uploaded - HUPHandler installs a handler onto a Unix/Linux system that catches SIGHUP. This signal is commonly used to re-initialize a server application; I'm using it on this server to catch SIGHUP and:
| Edit | Rename | Upload | Download | Back to Top |