![]() |
| | #1 |
| Registered User Join Date: Apr 2003
Posts: 23
| readlink segmentation fault Code: if( S_ISLNK(mode) )
{
type = 'l'; /*symlink*/
readlink(fileName, buf, sizeof(buf));
printf("\n %s \n",buf);
}
|
| Schwarzhelm is offline | |
| | #2 |
| Registered User Join Date: Mar 2003
Posts: 143
| Very difficult to say for certain without knowing exactly what readlink() does, but segmentation faults usually arise when you write over the end of allocated memory. My suspicion would be on buf. How is it declared? Is it big enough to hold the string? Is sizeof(buf) giving you the answer you expect? |
| DavT is offline | |
| | #3 |
| Registered User Join Date: Apr 2003
Posts: 23
| I have buf declared as a char *buf. I tried the code that was suggested and it is still getting a segmentation fault. filename is dirp->d_name after a lstat. Thank you. |
| Schwarzhelm is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Why am I getting segmentation fault on this? | arya6000 | C++ Programming | 6 | 10-12-2008 06:32 AM |
| Segmentation fault | bennyandthejets | C++ Programming | 7 | 09-07-2005 05:04 PM |
| Segmentation fault | NoUse | C Programming | 4 | 03-26-2005 03:29 PM |
| Locating A Segmentation Fault | Stack Overflow | C Programming | 12 | 12-14-2004 01:33 PM |
| Segmentation fault... | alvifarooq | C++ Programming | 14 | 09-26-2004 12:53 PM |