Bad File Descriptor Error In Unix
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might
Bad File Descriptor Socket
have Meta Discuss the workings and policies of this site what is bad file descriptor About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting bad file descriptor c ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7
Bad File Descriptor Error In C
million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Bad File Descriptor with Linux Socket write() Bad File Descriptor C up vote -1 down vote favorite I have an interesting problem with write(2) function. PrepareResponseForSetCoordinates function causes bad file descriptor error on write. Here is the line
What Does Bad File Descriptor Mean
of error: perror("ERROR writing to socket"); total output: ERROR writing to socket: Bad file descriptor I am sure that I have established the connection because PrepareResponseForConnectionTest works like a charm. Can you have any idea about the reason of the error? When I use gcc as compiler there was no problem. After that because of using multiple new cpp sources I am using g++ as compiler and I have this error. Regards Here below my code: #define MAX_PMS_MESSAGE_LEN (4096) unsigned char baCommBuffer[MAX_PMS_MESSAGE_LEN]; unsigned char PrepareResponseForSetCoordinates(void) { unsigned char baTempBuff[255]={0}; unsigned short bCnt=0,i=0,bCsum=0,bCnt2=0; time_t lEpochTime; time_t lSessionTime; memset(baTempBuff,0,sizeof(baTempBuff)); memset(baCommBuffer,0,sizeof(baCommBuffer)); bzero(baCommBuffer,MAX_PMS_MESSAGE_LEN); bzero(baTempBuff,sizeof(baTempBuff)); lEpochTime = time(NULL); baCommBuffer[bCnt++] = START_CHAR; baCommBuffer[bCnt++] = START_CHAR; baCommBuffer[bCnt++] = PACKET_SEPERATOR; sprintf((char*)baTempBuff,"%ld",(unsigned long)lEpochTime); memcpy(baCommBuffer+bCnt,baTempBuff,10); bzero(baTempBuff,sizeof(baTempBuff)); bCnt+=10; baCommBuffer[bCnt++] = PACKET_SEPERATOR; // lSessionTime = time(NULL); if(SPMSMessage.lSessionID) lSessionTime = SPMSMessage.lSessionID; else lSessionTime=lEpochTime; sprintf((char*)baTempBuff,"%ld",(unsigned long)lSessionTime); memcpy(baCommBuffer+bCnt,baTempBuff,10); bzero(baTempBuff,sizeof(baTempBuff)); bCnt+=10; baCommBuffer[bCnt++] = PACKET_SEPERATOR; baCommBuffer[bCnt++] = PMC_ID; baCommBuffer[bCnt++] = PACKET_SEPERATOR; baCommBuffer[bCnt++] = PMS_ID; baCommBuffer[bCnt++] = PACKET_SEPERATOR; baCommBuffer[bCnt++] = 'R'; baCommBuffer[bCnt++] = 'E'; baCommBuffer[bCnt++] = 'P'; baCommBuffer[bCnt++] =
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 bad file descriptor shell script About Us Learn more about Stack Overflow the company Business Learn more about
Bad File Descriptor Vlc
hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join bad file descriptor pipe 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: Sign up Bad file descriptor up http://stackoverflow.com/questions/11258781/bad-file-descriptor-with-linux-socket-write-bad-file-descriptor-c vote 11 down vote favorite 1 I'm learning about file descriptors and I wrote this code: #include
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 company Business Learn more about hiring developers or http://unix.stackexchange.com/questions/115467/getting-bad-file-descriptor-error-during-tar posting ads with us Unix & Linux Questions Tags Users Badges Unanswered Ask Question _ Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes http://www.unix.com/shell-programming-and-scripting/216141-error-o-p-says-bad-file-descriptor.html a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Getting “Bad file descriptor” error during tar up vote 1 down vote favorite I'm trying bad file to tar a dir with this command "tar -cpSWf myfile.tar workdir; gzip myfile.tar", but I get this error for some of the files in workdir dir. tar: my/sub/dir/file1.oa: Cannot seek to 1536: Bad file descriptor I run the same command on other dir and there's no such error. Is it because the .oa files are corrupted, or the disk is failing? Is this a common issue when using tar? Is there any way to repair this error? linux tar share|improve this question asked bad file descriptor Feb 17 '14 at 2:53 user11496 1641618 That's probably the detection of sparseness that causes it. –Stéphane Chazelas Feb 17 '14 at 7:19 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted Questions Is it because the .oa files are corrupted, or the disk is failing? Is this a common issue when using tar? Is there any way to repair this error? It isn't really relevant whether this issue is typical or not (I've not encountered it before), I'd start by attempting to tar up a single file and see if can't isolate the issue a bit more, and also repeat it. $ tar -cpSWf somefile.tar my/sub/dir/file1.oa Also as an aside, you can save yourself a step and tar and compress all at once: $ tar zcpSWf somefile.tar.gz ... I would also look to take out the SW switches temporarily to see if that has any impact on your ability to tar these problematic files too. If these errors are a warning that there are bad sectors on the HDD you might need to run an fsck or use a tool such as HDAT2 to attempt to repair any damaged sectors. This repair work may still leave the .oa file in a corrupted state, however. share|improve this answer answered Feb 17 '14 at 3:22 slm♦ 164k40298469 Thanks slm. If I remove "SW", there is no error. I also find that by copying the workdir to another partition
Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here. Search Forums Show Threads Show Posts Tag Search Advanced Search Unanswered Threads Find All Thanked Posts Go to Page... learn linux and unix commands - unix shell scripting Error in the o/p says bad file descriptor... Shell Programming and Scripting Thread Tools Search this Thread Display Modes #1 02-15-2013 nikhil jain Registered User Join Date: Apr 2011 Last Activity: 31 August 2016, 9:27 AM EDT Location: Bangalore Posts: 163 Thanks: 35 Thanked 2 Times in 2 Posts Error in the o/p says bad file descriptor... Code: Code: grt=`sort -nr line_count.txt|head -1` while read $dline do if [ "$grt" -eq "`wc -l combo_operncount.$dline|awk '{print $1}'`" ] then awk -F, '{print $1}' combo_operncount.$dline > FULLD7 else echo combo_operncount.$dline >> filecoll.txt fname=`cat filecoll.txt|tr -s "\n" " "` echo $fname #paste FULLD7 combo_operncount.$dline fi done Error is thrown where it is highlighted Remove advertisements Sponsored Links nikhil jain View Public Profile Find all posts by nikhil jain #2 02-15-2013 busyboy Registered User Join Date: Jan 2010 Last Activity: 6 September 2016, 7:36 AM EDT Posts: 195 Thanks: 2 Thanked 9 Times in 9 Posts try assinging the value of the Code: wc -l to a variable before going to test. Also enclose the variable $dline inside "" Code: ~# grt=`sort -nr filename|head -1` ~# JJ=`wc -l filename."$KK"| awk '{ print $1 }'` ~# if [ "$grt" == "$JJ" ]; then echo $JJ; else echo "Not true"; fi Not true Remove advertisements Sponsored Links busyboy View Public Profile Find all posts by busyboy #3 02-15-2013 nikhil jain Registered User Join Date: Apr 2011 Last Activity: 31 August 2016, 9:27 AM EDT Location: Bangalore Posts: 163 Thanks: 35 Thanked 2 Times in 2 Posts I dint get wat u aiming to explain.... nikhil jain View Public Profile Find all posts by nikhil jain #4 02-15-2013 busyboy Registered User Join Date: Jan