- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Wow .. you are wrong, because if you look at the code behind the 'sleep' command (i think they keep 'em in the bin folder or something) you will see that a date/time variable is created to hold the end time, which will overflow during execution.
You could test this by changing the system date (adding 999999990) while it is executing to see which is the case. If it ends in 10 seconds....
I really don't care though.
Admin
that is assuming that said person has time / interest in persuing a relationship with an actual person (apposed to talking to his/her pc late on a friday night when no one is around).
Admin
And, just for kicks (it took me a while to do this as I didn't have an easy arbitrary-precision calculator lying around...) it would mean that in order for 1 atom of Carbon-14 to be left at the end of that time, you'd have to start with 3.61*10^(307,050,059) atoms, which works out to about 8.40*10^(307,050,036) kg of Carbon-14.
I apologize for boring you with that information. I'll quietly go back to work now. I find it rather appropriate that the captcha test is "perfection" this time. Though, "pathetic" might have been better....
Admin
<CTRL>I<CTRL>B<CTRL>U<CENTER><CTRL>V</CENTER><CTRL>U<CTRL>B<CTRL>I
Admin
Arrrrrrrrrrrrggggggghhhhhh - I hate using FrontPage as an editor - sorry for the garbled gibberish
Admin
I give up. Yes, I am aware -1.02*10^8 is negative. You were undoubtedly trying to be helpful, which is to be commended. However, no more sarcasm from me, ever.
Until, of course, the next time I post.
Admin
Greetings earthlings, I am Uatu, the watcher. For epochs, I have observed your server with interest and fascination. I now break my vow of silence and non-interference to assist you in dealing with Scripticus - the devourer of servers. Now that time has passed 2^31-10^9, the Herald of Scripticus, the Silver Sleeper, will find your server so Scripticus can satisfy his world devouring hunger.
Johnny Storm, I will send you to the homeworld of Scripticus so you can find the Very Nullifier. Make haste, for if you find it in time, Reed Richards will be able to use it to shave a zero off the sleep command - thus sparing your world until time 2^31-10^8. Susan Storm Richards, your husband has already realized that this will mean rebooting the server every three years. And so, it falls to you to use your powers to make this reboot.... transparent to the end user.
Admin
*searches for a new sarcasm detector on ebay*
(uh-oh, unblockable ads!)
Admin
Wow, the WTF is you don't understand the WTF. There is no easy way to do "sleep for x seconds" other than to add x to the current time to determine the wakup time. It is the result of this addition that is overflowing the maximum value for the number and thus going to negative. I would guess the sleep command does not do any extensive testing to make sure this overflow doesn't happen, as it expects the caller of the sleep command to use it in a reasonable manner.
Although I assume the best way to implement a sleep function would be to store both the time sleep was called AND the offset, and use both of those to test against the current time, instead of just adding the duration to the time the sleep was called to determine the wakup time.
i.e. this function would say whether a process that called sleep at time_sleep_was_called with a duration of duration_of_sleep should wake up yet. It should allow you to use the maximum duration storable in a time variable without overflow, though it might never wake up if the current clock overflows, but that is a whole other problem now, isn't it.
function should_it_wake_up_yet( time_sleep_was_called, duration_of_sleep ) {
return ( get_current_time() - time_sleep_was_called ) < duration;
}
Admin
Sound's like Oracles WTF to me...
Admin
Admin
start oracle
sleep 100000
sleep 100000
(repeat as needed)
stop oracle
Admin
The real WTF would be:
- nohup cat < gasolinetank match|light &
Should be safe enough running in the background...Admin
I understand why rebooting would cause the overflow/shutdown, but how could this bug be the cause of the server going down to begin with, barring it last being down in the seventies? You aren't adding the current time to the sleep time except at script bootup.
Admin
he startup script should have run for 1000000000 seconds from the time it was started, regardless of the date.
Actually having a buffer and incrementing (or decrementing your choice) it every second is not exactly a sane choice. If anything hangs the system for a while, then your buffer is not incremented (or decremented) in a while which can cause some oddities. Of course you could resort to real time interrupts or kernel space timer to circumvent the problem, but that is not considered sane either (at least when your are not in a time critical application).
So basically you can gobble up ressources to keep your buffer acurate, or you can simply add the current timestamp with the sleep time, put the result in a variable and compare it from time to time with the new current time stamp. This of course has some disavantages: for example invoquing sleep(100) won't assure you that your script will actually sleep for 100 seconds exactly, it will sleep for at least 100 seconds, but it could be more if the system is under a heavy load. I guess that is why programmer dealing in real time are so overpaid, they can't use niceties such as sleep (in fact they tend to avoid shell scripting as well)
Note that the WTF is still double. An oracle application staying up for three years is nothing that extraordinary (though it is rare) so setting 10^8 instead of 10^9 is a little bit pessimistic. Without sufficient time or knowledge to check wether the sleep is actually usefull, I would have gone for 0.5*10^9 - 16 years maximum uptime and 16 years without upgrade of the starting script both seems unreasonable. A comment added would be a nice touch.
Admin
"There is no easy way to do "sleep for x seconds" other than to add x to the current time to determine the wakup time"
huh?
int main(int argc, char** argv) {
time_t duration = (time_t) atol(argv[1]);
time_t start = time(NULL);
for(;;) {
time_t now = time(NULL);
if( (now - start) >= duration)
return 0;
}
}
I guess it's theoretically possible for the result of the subtraction to be somehow undefined or unexpected depending on the computer. And certainly duration is limited by the capacity of either long int (atol) or time_t (probably also a long int), whichever is smaller.
[In reality though, the sleep(1) command just calls the sleep(3) function, or alarm(); pause();, not a busywait like that.]
It's really a bug in the sleep command, it should probably return immediately and print an error if its argument is too big.
Admin
You keep on using that phrase... I do not think it means what you think it means...
Admin
sweet, a nested wtf
i cant believe my "fist" post got taken down...like everybody else's post is more meaningful? pish
Admin
"Sound's like Oracles WTF to me..."
A "startup" script run as a command that properly runs a daemon in the background, or properly tells it to quit, and then exits back to the shell is completely standard Unix procedure. Fire and forget, and it runs correcly in the background as a daemon. This WTF script that sleeps is a stupid hack that for some unimaginable reason intentially tries to defeat this procedure.
Do they run this script at the server console or something? Or just hope that their remote terminal never exits... ? What if you want to remotely restart oracle -- if you keep using this script you end up with N of them all just sleeping...
Admin
"The number of seconds since 1/1/70? WTF?"
Actually, there are two things us Windows guys don't understand.
1) You count in seconds? WTF?
2) You use 32 bits for time? WTF?
Windows guys, at least of the NT persuasion, use a 64-bit count of the number of 100nS ticks since 1/1/1601.
We don't have no steenkin' 2038 bug.
capcha: genius
"Why, thanks!"
Admin
I guess they want to be able to stop Oracle by killing the sleep process, for whatever reason... Maybe they hoped that this would cleanly shut down Oracle in case of a system shutdown, without a shutdown script that has to be installed by root.
Admin
hmmm...
Admin
Easily : if the sleep command does something like this
int sleep_end = get_time_in_seconds_since_epoch_start() + get_sleep_duration();
while (get_time_in_seconds_since_epoch_start() < sleep_end) do_nothing();
then it will easily crash... I think someone explained this earlier in the thread.
Admin
Don't you mean... (and it sorrows me that nobody else has made this joke yet)...
the EPOCHalypse?
Admin
Except that Unicode doesn't actually have Klingon character set... Unicode folks rejected it because everyone who studies Klingon uses Latin characters anyway. It's in ConScript though. (http://www.evertype.com/standards/csur/klingon.html)
And exactly for the same reason, I don't really care about Klingon letters in Unicode. But where's my frigging Tengwar?
Admin
Hey!
Would this fool Uatu?
~~~~~~~~~
start oracle
sleep 100000
sleep 10000
sleep 1000
sleep 100
sleep 10
sleep 1
stop oracle
~~~~~~~~~
And last as long as possible?
(I know some programmer type could use an "var n--" loopey thing to make that more elegant, but I ain't no programmer.)
Admin
http://en.wikipedia.org/wiki/Carbon-14
The half-life of carbon-14 is 5730 years.
Admin
I think it's funny. Maybe no one else remembers Galactus.
edit: I swear I quoted the Watcher post...
Admin
Admin
We had a Java web front end to an old mainframe (cobol ims/db) system. When we added a new piece of functionality we struck an interesting variant of the same problem. We started to see occasional dates that were obviously corrupted in some fashion but there were no exceptions being generated even though the date being displayed was <FONT size=2>07/06/10007. Turns out that during the date conversion process java is lenient by default and was quite happy with a date of 99/99/9999...
Admin
So does that take account of the eleven days taken out of September 1752 or not?
Admin
Actually, i don't see the point in the sleep there. But if it is required (for any reason unknown to me), i don't think it is intented to ever end. So why not using:
while true; do sleep 1; done;
(more expert shell-magic also possible :)
Admin
I would say that in general I would take a self taught programmer who has worked over the past 4 years over a fresh graduate, but after a few years a solid foundation learned over those years should allow the average schooled programmer to surpass her self taught counterpart. A programmer with a 4-year degree and 6 years of experience is probably a better bet than one with 10 years of experience and no formal learning in the subject.
Admin
Sadly, there was an article in Time that explained why that's never going to happen, the universe needs to have a decreased acceleration over time for that to happen, and its having a positive acceleration. So this will need to be updated long before the heat death of the universe in T-1.0e10^100 years from now.
Admin
:shakes head:
that would mean this process is always running and taking cpu time.
what he should've done is sleep -1 if the command supports it, or wait on some mutex/object that won't be released.
Admin
The REAL WTF is that your happy being M$'s PlayThing(tm).
Admin
Ha ha, good one!
Admin
WTF? You want us to refer to women as "boyfriends?"
Admin
because you would have to run other commands like "jobs'' ,"nice" , "fg", "bg"...and others to monitor and stuff....
http://www.physics.utah.edu/~detar/lessons/basic_unix/basic_unix/basic_unix.html
besides...don't you need the client to come back to you for "maintenance & updates" ?
As a "Marketing Director" said once to me ..."It's easy to make new clients, it's harder to keep them..."...but in my head that sounded "It's easy to fool anybody, it's harder not to get caught for a long time..."...that's when "Re-branding, Aggresive Advertising and Special Offers" kick in
If I were the dev. responsable for that app, i would have written the "startup script" in Assembler, and compiled it with GCC...and if it overflowed...that would have been a problem. ;)
Admin
Yanks eh? Given enough time etc...
Admin
I think this time as a big integer is handy. If you sould calculate 96 hours from a date its better to diff 2 unixtimes ( or 'nttimes' ) than implement all the complex and strange rules about dates, leap years, etc.
Handy mean is usefull for quickanddirty code, but theres something out here better, doing this the long and painfull way.
Why write quick and dirty code?, well.. simple code often have less errors. And know problems. While complex and convulated code as unknowm problems, and much hard to read, mantain or fix code.
The sizeof 32 bits its because this is legacy from filesystems. And filesystems are designed to be fast and store lotsa data. Having metadata stored as smaller posible size seems a good idea. And 32 bits whas sound like a good idea for a filesystem on year (no idea), 2038 its like the future future, with space ship wars, fliing cars, dukenukem forever and windows vista service pack 2.
Legacy its like that, ugly, old and boring. On windows you have lots of legacy from MS-DOS and Windows 3. A monouser enviroment, and a graphical interface built on top of MS-DOS. Single and small legacy problems are hard to repair and deep.
On Windows a file is locked if a app has open it. But this lock mean other app can open the file and corrupt it. Can't delete, but can corrupt. This lock mean Windows can't update itself, and need a restart to update files. This is because the MS-DOS legacy.
etc.. sorry the long post, theres here people that know zimbillions more than me about any topic on this post so.. I feel retard writing this here :I
--Tei
Admin
Galactus is one of my favourites! Even named a character Galactus on NannyMUD (as if that would interest anyone, WTF???).
Admin
His WHAT? His happy??? WTF??? So his happy is some PlayThing? WTF?!? (I'm trying hard NOT to get a picture of this 'happy' of his...)
Admin
Well, no. Radioactive dacay is a random process. So you might run out of the tiny rest of that customer years before. Or the last customer atom might stay with you for thousands of years. You can't know in advance, well not considering contemporary knowledge of quantum mechanics.
Anyway customers consisting only of C-14, I'd reject anyway. They're too active, radio active infact. Of course customers who lack carbon entirely, aren't fun to work with either.
Admin
The & is quite obviously not needed here. If it were, the startup script would never have reached the "sleep" line unless someone manually shut down Oracle first.
Yes, Oracle obviously keeps on running after the "start oracle" comand, but I guess the "start" command itself doesn't. Conceivably the "start" is itself some kind of script, and there's a & somewhere in there already?
Admin
Sounds like the "start oracle" command doesn't detach the oracle instance(s) it starts, and that the script stopping is bad mojo for the started instances. Looks like a hacky kludge to me, generally speaking you'd use a proper startup script that did stuff like storing the pid of the process etc. It's not like these are exactly unknown, googling "oracle startup script" will provide ample examples. So, is this script actually part of Oracle itself (in which case it's a fairly massive WTF) or just some clueless supplier providing worthless support?
So clue us in, oh Oracle gurus. Does this come from ${ORACLE_ROOT}/bin/dbstart, or is it from elsewhere?
Simon
Admin
CAPTCHA: chocobot
that's me ffs!
Admin
32bit time_t is a property of the C library, not operating system - Linux internally also uses 64 bits for times. BTW, sleep 1000000000 (bash internal) and /bin/sleep 1000000000 (GNU coreutils 5.94) seem to work just fine on my linux boxes.
Admin
HECK, why don't they just make the number unsigned, to EASILY add 160 years????
Steve
Admin
You obviously missed the Software Engineering class that taught: "You cannot fix problems only delay them." Otherwise how could you have any job security? These guys are just making sure they'll have another tech support call in the future.