Bad File Descriptor Error 9
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the error 9 bad file descriptor python company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions
Xen Error 9 Bad File Descriptor
Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million bad file descriptor error in c programmers, just like you, helping each other. Join them; it only takes a minute: Sign up What could be the reason for a socket error “[Errno 9] Bad file descriptor” up vote 5 down vote favorite bad file descriptor golang I have a complex python (2.7.3) script which is trying to open a socket connection via self.socket.close() # doing something else self.socket.connect((host, port)) but all I get is the following socket error: error: [Errno 9] Bad file descriptor The host:port accepts connections as I have verified this with nc host port manually. So what could be the possible reasons I get this error for opening a connection to the given port, which actually works?
Bad File Descriptor Mac
I cannot and will not post the full script as it is too complex and irrelavent for this question. I just would like to know all possible reasons for this error, and how to check them and fix them. python sockets python-2.7 share|improve this question asked Jun 20 '13 at 6:53 Alex 7,5521666133 3 Read the documentation for socket.close(). You cannot reuse it in any operation (including connect) once you close it. It needs to be reinitialized with a call to socket.socket. –Thomas Jun 20 '13 at 6:58 add a comment| 1 Answer 1 active oldest votes up vote 18 down vote accepted You will need to create a new socket object. Maybe self.socket = socket.socket() after closing the previous socket and before connecting. share|improve this answer answered Jun 20 '13 at 6:58 Atmaram Shetye 661413 Bongo that's it! Thank you very much. –Alex Jun 20 '13 at 7:02 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer you're looking for? Browse other questions tagge
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies bad file descriptor perl of this site About Us Learn more about Stack Overflow the company bad file descriptor bash Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges
How To Fix Bad File Descriptor
Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: http://stackoverflow.com/questions/17207051/what-could-be-the-reason-for-a-socket-error-errno-9-bad-file-descriptor Sign up What can lead to “IOError: [Errno 9] Bad file descriptor” during os.system()? up vote 27 down vote favorite 2 I am using a scientific software including a Python script that is calling os.system() which is used to run another scientific program. While the subprocess is running, Python at some point prints the following: close failed in file object destructor: IOError: http://stackoverflow.com/questions/7686275/what-can-lead-to-ioerror-errno-9-bad-file-descriptor-during-os-system [Errno 9] Bad file descriptor I believe that this message is printed at the same time as os.system() returns. My questions now are: Which conditions can lead to this type of IOError? What does it exactly mean? What does it mean for the subprocess that has been invoked by os.system()? python subprocess posix file-descriptor ioerror share|improve this question edited Apr 24 at 0:10 Aminah Nuraini 2,0491226 asked Oct 7 '11 at 10:54 Jan-Philip Gehrcke 13.4k14073 1 Note: using the subprocess module is preferable over os.system(). –Petr Viktorin Oct 7 '11 at 11:07 :-) I know that and there is a lot of non-perfect stuff in this software. –Jan-Philip Gehrcke Oct 7 '11 at 11:15 add a comment| 2 Answers 2 active oldest votes up vote 22 down vote accepted You get this error message if a Python file was closed from "the outside", i.e. not from the file object's close() method: >>> f = open(".bashrc") >>> os.close(f.fileno()) >>> del f close failed in file object destructor: IOError: [Errno 9] Bad file descriptor The line del f deletes the last reference to
years ago Bad file descriptor error in accept or bind or listen Reported by: jlawrence Owned by: Priority: normal Milestone: Component: other Version: trunk Keywords: Cc: Description (defun run-server http://trac.clozure.com/ccl/ticket/1050 (host port out) (with-open-stream (server (ccl:make-socket :connect :passive :local-host host :local-port http://linux.sys-con.com/node/1053821 port :reuse-address t)) (with-open-stream (stream (ccl:accept-connection server)) (format out "~s~%" (read stream)) (print :pong stream) (finish-output stream)))) (defun make-socket/retry (host port tries) (loop (handler-case (return (ccl:make-socket :remote-host host :remote-port port)) (ccl:socket-creation-error (err) (unless (plusp (decf tries)) (error err)) (format t "retry~%") (sleep bad file 0.1))))) (defun test (host port) (ccl:process-run-function "server" #'run-server host port *standard-output*) ;(sleep 0.001) (with-open-stream (stream (make-socket/retry host port 5)) (print :ping stream) (finish-output stream) (format t "~s~%" (read stream)))) (defun run () (loop for port from 10000 to 20000 do (test "localhost" port))) Failure happens within three iterations on my machine. retry :PING :PONG bad file descriptor retry > Error: on #
HAT RUBY SAP SEARCH SILVERLIGHT SYMBIAN VIDEO VIRTUALIZATION WEB 2.0 WEBLOGIC WEBSPHERE WIRELESS XML Home Subscribe Advertise Authors Topics Videos Events Webcasts Internet of Things | Cloud | Big Data | DevOps | Containers | Microservices | WebRTC | Java | Linux | Open Stack | Mobile | Security | SDDC Linux Containers Authors: Ian Khan, Yeshim Deniz, Liz McMillan, Elizabeth White, Sematext Blog Related Topics: Linux Containers Linux Containers: Article Bad File Descriptor Error in Linux Stellar Phoenix Linux Data Recovery is a comprehensive data recovery tool By Allen Sood Article Rating: Select ratingGive it 1/5Give it 2/5Give it 3/5Give it 4/5Give it 5/5 July 30, 2009 04:30 AM EDT Reads: 69,278 Related Print Email Feedback Add This Blog This In a Linux system, files, blocks, directories, sockets and other items are referred by corresponding file descriptors. If your system is reporting errors that the file descriptor is bad, one of possible causes is that file system is corrupt and thus, you require restoring from backup. But if backup is not valid enough to restore complete information, you need to use advanced Linux Data Recovery applications. As an instance, you might encounter the below error message with your Linux based system: “Bad file descriptor” You might receive this error while trying to access a file or while trying to boot the system. Cause Possible reasons for the ‘Bad file descriptor’ error to occur are: Linux systems use a special file, called /dev/null (also called the null device). This file removes all the data that is written to it after reporting that the write process has successfully succeeded. You might receive the above error message if /dev/null has been deleted or overwritten. You can infer this cause when file system is reported as read-only at the time of booting through error messages, such as“/dev/null: Read-only filesystem” and “dup2: bad file descriptor” If you get this error message while trying to access a file, the most prominent causes are file system corruption or damaged disk block(s). In such situations, you also get write errors. Solution You need to use these methods to troubleshoot the above behavior: For solving deleted or overwritten