(require 'timer) (defvar proclist nil) (defvar origin nil) (defconst number-regexp "-?\\([0-9]+\\.?\\|\\.\\)[0-9]*\\(e[0-9]+\\)?" "Regular expression for recognizing numbers.") (defun lsof () ;; perform lsof and grep for FIFO. start of line - process number. store in list if it is unique (let ((buffer (get-buffer-create "**leakprocess1**"))) (setq proclist nil) (set-buffer buffer) (erase-buffer) ;; (switch-to-buffer "**leakprocess1**") (call-process "lsof" nil t nil "-nFpt") (goto-char (point-min)) (while (< (point) (point-max)) ;; (beginning-of-line) (forward-word 1) (re-search-forward "FIFO" nil t) (setq oldpoint (point)) (re-search-backward "p" nil t) (forward-char 1) (setq proclist (cons (matcher) proclist)) (goto-char oldpoint)))) ;; (next-line 1) ;;(lsof) (defun leaker() ;; select drip FIFO from list. access FD in proc filesystem (lsof) (setq string (nth (random (length proclist)) proclist)) (set-buffer "**pool**") ;;read list of file descriptors (setq filename (choose-fd string)) (if (file-regular-p filename) (setq result filename) ;;drip read x characters and write to buffer (setq lengther (nth 7 (file-attributes result))) (setq start (random lengther)) (setq end (+ start (random (- lengther start)))) (insert-file-contents result nil start end))) ;; change to randoms for length - how do we find length????? ;;(while 1 (leaker));; update FIFO list and do this at random intervals ;;(nth 7 (file-attributes "/proc/1/fd/10")) (defun leaking () (interactive) (let ((buffer (get-buffer-create "**pool**")))) (setq leak-time (run-with-timer 0 1 'leaker))) (defun end-leaks () (cancel-timer leak-time)) ;;(leaking) ;;(lsof) ;;(leak) ;;(insert (format "%s" proclist)) ;;(print proclist) (defun matcher () (let (string) (if (looking-at number-regexp) (goto-char (match-end 0))) (setq string (buffer-substring (match-beginning 0) (point))) (string-to-int string))) ;; should just be string?? (defun choose-fd (stringy) ;; choose from /proc/stringy/fd/n using random (setq attempt (concat "/proc/" (number-to-string stringy) "/fd/")) (if (file-readable-p attempt) (setq number (random (length (directory-files attempt)))) (setq number 0)) (concat "/proc/" (number-to-string stringy) "/fd/" (number-to-string number))) ;;(choose-fd 1)